Skip to main content

Library for transformation and conversion of coordinates used in Equinor.

Project description

Geodetic Engine

A Python library using the Equinor Geodetic Engine API and pyproj to transform coordinates between different Coordinate Reference Systems (CRS).

Installation

  1. Access to the Equinor Geodetic Engine API is required, which can be obtained through AccessIT.

  2. A personal subscription key is also necessary to authenticate through APIM. Sign in to api.equinor.com and subscribe to Enterprise.

  3. As usual the package it´s installed running pip install:

pip install geodeticengine

Authentication

There are two ways to authenticate:

  • User access - MSAL Device code flow
  • Application access - MSAL Client credential flow

User access - MSAL Device code flow

This package uses the PublicClientApplication Python class from the MSAL library for user authentication. Bearer tokens are retrieved using the acquire_token_interactive() method, which can be accessed via a local browser on devices that support a Graphical User Interface (GUI). If a device lacks GUI support, such as GitHub Code Spaces, the initiate_device_flow() method generates a specific URL for the user to visit and follows a standard authentication and login process.

In order to use the package with user access to production, you will only need to add one environment variable to your system:

EGE_SUBS_KEYS=<your-subscription-key-for-geodeticengine-prod>

In order to use the package with user access to test, you will need to add the following environment variables to your system:

EGE_API_ENV=test
EGE_SUBS_KEYS=<your-subscription-key-for-geodeticengine-test>

EGE_SUBS_KEYS: This variable holds your APIM subscription key for each environment (prod and test). This will allow the package to access the resources you have permission to use.
EGE_API_ENV: This variable is used to access the Geodetic Engine Test environment. If this environment variable is not set, the package will use the production environment by default. It can also be set to production, by EGE_API_ENV=prod.

User access - Token cache

The token for each environment is cached and stored in the user's home directory, eliminating the need to authenticate before every session. Although an access token expires after one hour, the presence of a cached Refresh Token allows a new Access Token to be obtained without requiring re-authentication. The Refresh Token lasts for 90 days, then you have to log in again.

Application access - MSAL Client credential flow

In order to use the package with application access to production, you will need to add the following environment variables to your system:

EGE_CLIENT_IDS=<your-app-id-prod>
EGE_CLIENT_SECRETS=<your-app-secret-prod>
EGE_SUBS_KEYS=<your-subscription-key-for-geodeticengine-prod>

In order to use the package with application access to test:

EGE_API_ENV=test
EGE_CLIENT_IDS=<your-app-id-prod>;<your-app-id-test>
EGE_CLIENT_SECRETS=<your-app-secret-prod>;<your-app-secret-test>
EGE_SUBS_KEYS=<your-subscription-key-for-geodeticengine-prod>;<your-subscription-key-for-geodeticengine-test>

EGE_API_ENV: This variable is used to access the different environments test and production. If this environment variable is not set, the package will use the production environment by default. It can also be set to prod, by EGE_API_ENV=prod. EGE_CLIENT_IDS: This variable holds your application (client) ID for each environment.
EGE_CLIENT_SECRETS: This variable is used for your application's client secret for each environment. If this variable is not set, the package will automatically fall back to user access for authentication.
EGE_SUBS_KEYS: This variable holds your APIM subscription key for each environment (prod and test). This will allow the package to access the resources that you have permission to use.

Note that if the EGE_CLIENT_IDS, EGE_CLIENT_SECRETS and EGE_SUBS_KEYS environment variables hold the IDs and secrets for both the production and test environments, the order is important. The production values must always come before the test values.

Transformation grids

Transformation grids are essential for achieving high accuracy when performing datum transformations. The package will automatically fetch required grid if it doesn't already exist on your local machine.

More information on the data available is located in pyproj documentation.

Transformation code examples

from geodeticengine import CoordTrans

### Example 1
points = [[10, 60]]
crs_from = "EPSG:4230"
crs_to = "EPSG:4326"
ct_from = "EPSG:1612"

# Transform coordinates
ct = CoordTrans(crs_from=crs_from, crs_to=crs_to, ct_from=ct_from, points=points)
print(f"Transformed coordinates:{ct.transform_pointlist()}")

# Get transformation pipeline
pipeline = ct.get_pipeline()
print(f"Transformation pipeline: {pipeline}")


### Example 2
points = [[9,65],[12,70]]
crs_from = "ST_ED50_T1133"
crs_to = "ST_WGS84_G4326"

# Transform coordinates
ct = CoordTrans(crs_from=crs_from, crs_to=crs_to, points=points)
print(f"Transformed coordinates:{ct.transform_pointlist()}")

# Get transformation pipeline
pipeline = ct.get_pipeline()
print(f"Transformation pipeline: {pipeline}")


Query code examples - available in Test environment only

from geodeticengine import CrsQuery, CtQuery

### Example 1
crs_query = CrsQuery(types=["bound projected","projected"], polygon_coords=[[1.278828871805691,58.07568845044884],[3.690287338364835,59.20344381800123],[2.274239008972083,60.12176489296384],[-0.1274790229401068, 59.8722761692493]], target_crs="ST_WGS84_G4326")
print(crs_query.get_entities())

### Example 2
ct_query = CtQuery(types=["transformation","concatenated operation"], polygon_coords=[[1.278828871805691,58.07568845044884],[3.690287338364835,59.20344381800123],[2.274239008972083,60.12176489296384],[-0.1274790229401068,59.8722761692493]], source_crs="ST_ED50_G4230", target_crs="ST_WGS84_G4326")
print(ct_query.get_entities())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geodeticengine-1.0.8.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

geodeticengine-1.0.8-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file geodeticengine-1.0.8.tar.gz.

File metadata

  • Download URL: geodeticengine-1.0.8.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for geodeticengine-1.0.8.tar.gz
Algorithm Hash digest
SHA256 411bcd3b669609766e4e6a2a61f43aa41ea6ef68bdd455640f78c784b7934e68
MD5 43362d3756a7c1f343b425a37f3b06bd
BLAKE2b-256 90969c810beb1c881354ed2487bd11daacf09621acf66d68cefd27dd43808631

See more details on using hashes here.

File details

Details for the file geodeticengine-1.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for geodeticengine-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 c571c43ccb078f47ee61828e1cf1ab146b19f89991f8fc134b2caea0ac2f43a3
MD5 0f5eb7ae8ebc6230f210e7c434a4d2b3
BLAKE2b-256 ce3e99835339cac17202d51d2609b80a7bffae6284db88d4a0fd27a1868f4c64

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page