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 ct_fromform coordinates between different Coordinate Reference Systems (CRS).

Installation

  1. You need access to Equinor Geodetic Engine API, given through AccessIT

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

  3. As usual 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-based authentication using public client flows.

For user-based authentication, this API utilizes the PublicClientApplication Python class from the msal library to retrieve bearer tokens for user authentication. In cases where a device supports a Graphical User Interface (GUI), the acquire_token_interactive() method is used to obtain tokens interactively via the user's local browser. For devices that lack GUI support, such as GitHub Code Spaces, the initiate_device_flow() method is used If the device supports a Graphical User Interface (GUI), the acquire_token_interactive() method will be used. This method acquires token interactively i.e. via a local browser. If the device does not support GUI, like GitHub Code Spaces for instance, the method initiate_device_flow() which generates a code for the user to visit a specific URL. The webpage then guides the user through the standard authentication and login process. This allows for a flexible and secure user authentication process that works across multiple devices.

To use the package with user-based access, you will need to add the following environment variables to your system:

EGE_CLIENT_ENVS=prod;test
EGE_CLIENT_IDS=c25018ed-b371-4b37-ba4e-4d902aee2b6c;84c8d2ec-6294-47aa-8fd4-f69c870faa3a
EGE_TENANT_ID=3aa4a235-b6e2-48d5-9195-7fcf05b459b0
EGE_RESOURCE_IDS=c25018ed-b371-4b37-ba4e-4d902aee2b6c;84c8d2ec-6294-47aa-8fd4-f69c870faa3a
EGE_SUBS_KEYS=<your-subscription-key-for-geodeticengine-prod;your-subscription-key-for-geodeticengine-test>

EGE_CLIENT_ENVS sets the order of environment variables. If you only have access to "prod", simply add "prod" to this variable.
EGE_CLIENT_IDS sets the client IDs for each environment. For user access, this is the same as EGE_RESOURCE_IDS. EGE_TENANT_ID is the tenant ID (Equinor).
EGE_SUBS_KEYS is your APIM subscription keys for each environment (prod and test). This will allow the package to access the resources you have permission to use.
EGE_RESOURCE_IDS is the resource ID of the geodetic engine for the specified environments.

Application access - MSAL Client credential flow

To use the package with application-based access, you will need to add the following environment variables to your system:

  • EGE_CLIENT_IDS
  • EGE_CLIENT_SECRETS

Add the following environment variables to your system:

EGE_TENANT_ID=3aa4a235-b6e2-48d5-9195-7fcf05b459b0
EGE_CLIENT_ENVS=prod;test
EGE_CLIENT_IDS=<your-app-id-prod;your-app-id-test>
EGE_RESOURCE_IDS=c25018ed-b371-4b37-ba4e-4d902aee2b6c;84c8d2ec-6294-47aa-8fd4-f69c870faa3a
EGE_SUBS_KEYS=<your-subscription-key-for-geodeticengine-prod;your-subscription-key-for-geodeticengine-test>
EGE_CLIENT_SECRETS=<your-app-secret-prod;your-app-secret-test>

When EGE_CLIENT_SECRETS is added, the authorization class will automatically use Application Access to authenticate.

Access test environment

To use the package to access Geodetic Engine Test environment, you need to set the EGE_API_ENV as an environment variable. If this environment variable is not set, the package will use the production environment.

EGE_API_ENV=test

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.

Code example

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}")

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.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

geodeticengine-1.0.1-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: geodeticengine-1.0.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for geodeticengine-1.0.1.tar.gz
Algorithm Hash digest
SHA256 067cbab4f5a2e9b901a060bdf499dcbb434550b26fd4b30264ae2bcdc0871ce8
MD5 bdb8c1432d870d17511448098eb341f3
BLAKE2b-256 6836bc4d434bce95a353dc0e4a6640b490f013a95ba6ff995d66cb84c8220e56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for geodeticengine-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c90dad631c3c6543d6365c6a86a038e9aeca50639f53eb6055b648f46b5b6c8e
MD5 6cfa52b50f88f9d63cf425e1fce59d57
BLAKE2b-256 fd6ce2f540b15474f2b708f28d9149014d713e6331d70f3c3b0b8f2d3459cc5f

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