Metadata-Version: 2.5
Name: pygeodetic-engine
Version: 0.2.0
Summary: Geodetic transformation engine built on PROJ, with provenance and quality control
Project-URL: Repository, https://github.com/equinor/geodetic-engine
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE
License-File: NOTICE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Scientific/Engineering :: GIS
Requires-Python: >=3.13
Requires-Dist: certifi>=2026.10.19
Requires-Dist: filelock>=4.2.1
Requires-Dist: httpx>=0.27
Requires-Dist: numpy>=1.26
Requires-Dist: pandas>=2.0
Requires-Dist: pyproj==3.8.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: shapely>=2.2
Provides-Extra: dev
Requires-Dist: hypothesis>=6.100; extra == 'dev'
Requires-Dist: import-linter>=2.1; extra == 'dev'
Requires-Dist: ipykernel<7,>=6.29; extra == 'dev'
Requires-Dist: jsonschema>=4.23; extra == 'dev'
Requires-Dist: kaleido>=1.0; extra == 'dev'
Requires-Dist: matplotlib>=3.9; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: nbformat>=5.10; extra == 'dev'
Requires-Dist: pandas-stubs>=2.0; extra == 'dev'
Requires-Dist: plotly>=6.1; extra == 'dev'
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
Requires-Dist: pytest-xdist>=3.0; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.6; extra == 'dev'
Requires-Dist: types-shapely>=2.1; extra == 'dev'
Provides-Extra: docs
Requires-Dist: furo>=2024.8; extra == 'docs'
Requires-Dist: kaleido>=1.0; extra == 'docs'
Requires-Dist: myst-nb>=1.2; extra == 'docs'
Requires-Dist: nbformat>=5.10; extra == 'docs'
Requires-Dist: plotly>=6.1; extra == 'docs'
Requires-Dist: sphinx-argparse>=0.5; extra == 'docs'
Requires-Dist: sphinx-autobuild>=2024.10; extra == 'docs'
Requires-Dist: sphinx-autodoc-typehints>=2.5; extra == 'docs'
Requires-Dist: sphinx-copybutton>=0.5; extra == 'docs'
Requires-Dist: sphinx-design>=0.6; extra == 'docs'
Requires-Dist: sphinx>=8.1; extra == 'docs'
Requires-Dist: sphinxcontrib-mermaid>=1.0; extra == 'docs'
Provides-Extra: plot
Requires-Dist: kaleido>=1.0; extra == 'plot'
Requires-Dist: nbformat>=5.10; extra == 'plot'
Requires-Dist: plotly>=6.1; extra == 'plot'
Description-Content-Type: text/markdown

<h1>
  <img src="https://raw.githubusercontent.com/equinor/geodetic-engine/main/docs/_static/logo.svg" alt="geodetic-engine" width="360">
</h1>

[![PyPI](https://img.shields.io/pypi/v/pygeodetic-engine)](https://pypi.org/project/pygeodetic-engine/)
[![Python](https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fequinor%2Fgeodetic-engine%2Fmain%2Fpyproject.toml)](https://pypi.org/project/pygeodetic-engine/)
[![Tests](https://github.com/equinor/geodetic-engine/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/equinor/geodetic-engine/actions/workflows/tests.yml)
[![Lint and type check](https://github.com/equinor/geodetic-engine/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/equinor/geodetic-engine/actions/workflows/lint.yml)
[![Documentation](https://github.com/equinor/geodetic-engine/actions/workflows/docs.yml/badge.svg?branch=main)](https://equinor.github.io/geodetic-engine/)
[![License](https://img.shields.io/github/license/equinor/geodetic-engine)](https://github.com/equinor/geodetic-engine/blob/main/LICENSE)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)

`geodetic-engine` is a Python library for transforming coordinates between
coordinate reference systems (CRSs) under explicit, verifiable rules. It is
built on [PROJ](https://proj.org) and
[pyproj](https://pyproj4.github.io/pyproj/stable/): PROJ performs the numerical
computation, while `geodetic-engine` determines which coordinate operation is
applied, validates the result before returning it, and records the provenance
required to reproduce and audit it. A transformation that cannot be carried out
exactly as specified is refused with an error rather than approximated.

**Documentation: <https://equinor.github.io/geodetic-engine/>**

- **Explicit operations.** A datum change must name its transformation, or use
  a bound CRS that names it. The operation named is the one applied.
- **Refuses untrustworthy results.** No ballpark approximations, no silent
  fallback when a grid is missing, no time-dependent transformation without a
  coordinate epoch.
- **Provenance on every result.** The applied operation, grids, epoch, the exact
  PROJ pipeline, and fingerprints of the `proj.db` that answered.
- **Numeric batches and lazy streams.** Reuse a `Transformation` with
  `transform_arrays()` for owned NumPy output buffers, or `transform_batches()`
  for lazy bounded batches, without constructing Python objects per output point.
- **OSDU `persistableReference` support.** Read and write the JSON/ESRI WKT
  envelope, and transform with exactly what it states.
- **Geometries.** Transform, convert and round geometries in WKT, WKB, hex
  WKB, PostGIS EWKT/EWKB, GeoJSON and Esri JSON with
  `Transformation.transform_geometry()`, with exact half-up rounding.
- **GeoJSON documents.** Convert RFC 7946 GeoJSON, OGC JSON-FG and OSDU
  AnyCrs GeoJSON to another CRS with `geodetic_engine.geojson.convert_geojson`,
  keeping structure and properties; a drop-in for the OSDU `convertGeoJson`.
- **Custom PROJ databases.** Add a Georepository register's or an OSDU
  catalogue's own CRSs and transformations to a copy of PROJ's `proj.db`.
- **Projection factors.** Grid convergence and scale factor of any projected
  CRS, with `geodetic_engine.geodesy.projection_factors`.
- **Well trajectories.** Minimum-curvature trajectories from directional
  surveys, placed in a CRS; see the
  [`welltrajectory` README](https://github.com/equinor/geodetic-engine/blob/main/geodetic_engine/welltrajectory/README.md).
- **Seismic bin grids.** Convert between bin grid and map grid with P6
  parameters, check and square up a four-corner grid, convert it to another
  CRS, and match a legacy dataset to a stored grid.

## Quickstart

```python
from geodetic_engine.geodesy import transform

# ED50 -> WGS 84 in Norwegian waters, with a named EPSG transformation.
result = transform("EPSG:4230", "EPSG:4326", (2.5, 63.5), operation="EPSG:1612")

result.coordinates        # ((2.49818..., 63.49961...),)   lon, lat: always xy order
result.operation.name     # 'ED50 to WGS 84 (23)'
result.operation.accuracy # 1.0 (metres)
result.pipeline           # the PROJ pipeline that ran, replayable in plain pyproj
```

Leave out `operation=` and the call raises `AmbiguousOperationError`, because
several ED50 to WGS 84 transformations exist and they disagree by metres. Use
`available_operations("EPSG:4230", "EPSG:4326")` to choose one.

## Installation

The library needs **PROJ 9.9.0** and **pyproj 3.8.0 built against it**,
because the EPSG dataset inside `proj.db` is part of every answer. Install the
released package and the matching wheel together:

```bash
pip install "pygeodetic-engine" "pyproj==3.8.0+proj9.9.0" \
    --extra-index-url https://equinor.github.io/geodetic-engine/simple/
```

The explicit wheel requirement also replaces a previously installed PyPI
pyproj wheel. If a matching wheel is unavailable, build pyproj from source
against the pinned PROJ instead. Importing the package rejects another PROJ
version rather than silently using its EPSG dataset. Wheels do not include the
full grid package; install the grids needed by your operations separately.

The wheel ships PROJ's database with the official OSDU catalogue already built
into it, and PROJ reads it once `geodetic_engine` is imported. OSDU CRSs,
record ids and persistable references resolve with no build step:

```python
import geodetic_engine
from pyproj import CRS

CRS.from_authority("OSDU", "2003001").name
# 'Grenada 1953 * DOS-Grd / British West Indies Grid [2003,1443]'
```

A database you chose yourself always wins: a `pyproj.datadir.set_data_dir()`
call before the import, or a `PROJ_DATA` (or `PROJ_LIB`) directory holding a
`proj.db`. `GEODETIC_ENGINE_OSDU_DB=0` turns the shipped database off, and
`geodetic_engine.osdudb.active_database()` reports which database PROJ reads
and why. `geodetic-osdudb build` still builds a newer or custom catalogue. See
[Installation](https://equinor.github.io/geodetic-engine/dev/getting-started/installation.html#the-osdu-database-the-wheel-ships).

For development, open the repository in VS Code and choose *Reopen in
Container*. By hand:

```bash
./.devcontainer/install-proj.sh                          # build the pinned PROJ
PROJ_DIR=/usr/local PROJ_WHEEL=false uv sync --extra dev # pyproj from source
uv run pytest tests/test_environment.py                  # verify
```

See [Installation](https://equinor.github.io/geodetic-engine/dev/getting-started/installation.html)
for details.

## Documentation

| | |
|---|---|
| [Getting started](https://equinor.github.io/geodetic-engine/dev/getting-started/index.html) | Installation, quickstart, core concepts |
| [User guide](https://equinor.github.io/geodetic-engine/dev/user-guide/index.html) | Transformations, OSDU payloads, the Georepository client, custom `proj.db` builds, seismic bin grids |
| [Examples](https://equinor.github.io/geodetic-engine/dev/examples/index.html) | Executed notebooks |
| [API reference](https://equinor.github.io/geodetic-engine/dev/api/index.html) | Every public class and function |
| [Command-line tools](https://equinor.github.io/geodetic-engine/dev/cli/index.html) | `geodetic-projdb`, `geodetic-osdudb` |
| [Known issues and workarounds](https://equinor.github.io/geodetic-engine/dev/workarounds.html) | What is worked around in PROJ, EPSG data, and the APIs, and when each can be removed |

To build the documentation locally:

```bash
uv run --extra docs sphinx-build -W --keep-going -b html docs docs/_build/html
```

## Development

```bash
uv run pytest                  # the usual run
scripts/run_all_tests.sh       # including the exhaustive dataset sweep
uv run ruff check geodetic_engine tests && uv run mypy geodetic_engine
uv run lint-imports            # the import layering contracts
```

See [Development](https://equinor.github.io/geodetic-engine/dev/development/index.html).
The PROJ, proj-data and pyproj releases are pinned in one file,
`.devcontainer/pins.env`; to move them, follow
[runbooks/upgrading-proj-and-pyproj.md](https://github.com/equinor/geodetic-engine/blob/main/runbooks/upgrading-proj-and-pyproj.md).

## License

See [LICENSE](https://github.com/equinor/geodetic-engine/blob/main/LICENSE).
