Skip to content

Altered proj.db containing NSGI defined transformations

License

CC-BY-4.0, MIT licenses found

Licenses found

CC-BY-4.0
LICENSE
MIT
LICENSE-CODE
Notifications You must be signed in to change notification settings

GeodetischeInfrastructuur/transformations

Repository files navigation

Transformations

GitHub license Static Badge GitHub Release

This repository contains a modified proj.db that implements the following transformations according to the recommendations of the NSGI (see image below).

transformations

  1. SQL which adds to the PROJ proj.db:

    • added NSGI to authority references
    • added extents of NSGI transformations
    • added additional NL datum (AGRS.NL)
    • added additional NL CRSs
    • added additional NSGI transformations
  2. A Dockerfile with PROJ configured to use this NSGI authority as a base (published on ghcr.io/geodetischeinfrastructuur/transformations)

These will form the base for the transformations that are defined or recommended by NSGI (Nederlandse Samenwerkingsverband Geodetische Infrastructuur). In the future additional transformations might be added to this repository.

⚠️ this repository contains 2 proj.db. The first (the default) proj.db has the sql scripts default/nl_nsgi_00... till default/nl_nsgi_05... applied. The second proj.time.dependent.transformations.db has the sql script time_dependent/nl_nsgi_00_time_dependent_transformations.sql applied for adding time dependent transformations. For this second proj.db, a input epoch should be provided (when applicable), to prevent the use of the default reference epoch of the transformation. When one wants to use this second proj.db this can be done in the following ways.

Through a move command

mv proj.db proj.db.bak
mv proj.time.dependent.transformations.db proj.db

or through the creating of a symbolic link

ln -s proj.time.dependent.transformations.db proj.db

Docker

The Docker image is intended to be used as a base image, for applications that layer on top of PROJ; for instance use it with pyproj, see the validate/Dockerfile file in this repo for an example.

The Docker image is published on the Github container registry: ghcr.io/geodetischeinfrastructuur/transformations.

Build

docker build -t geodetischeinfrastructuur/transformations:latest .

Run

To start an interactive terminal inside the container run:

docker run -it --rm geodetischeinfrastructuur/transformations:latest

To invoke projinfo from your current terminal sessions run:

docker run --rm geodetischeinfrastructuur/transformations:latest projinfo

To verify if the NSGI transformation EPSG:7931 -> EPSG:7415 works as expected, run the following in a terminal:

docker build validate/ -t geodetischeinfrastructuur/validate-transformations:latest 
docker run --rm -it geodetischeinfrastructuur/validate-transformations:latest python

Then run the following Python code:

from pyproj import transformer
etrf = transformer.TransformerGroup("EPSG:7931", "EPSG:7415")
"{0[0]:.4f} {0[1]:.4f} {0[2]:.4f}".format(etrf.transformers[0].transform(52.115330444, 7.684748554, 41.4160))

Alternatively the following cs2cs command can be used:

cs2cs -f "%.4f" EPSG:7931 EPSG:7415 <<< "52.115330444 7.684748554 41.4160"

Both should result in the following output: '312352.6004 461058.5812 -2.5206'

Validation

Running the full validation file can be done by running the following docker run command.

mkdir -p output # required otherwise output folder is created owned with root
docker run -u "$(id -u):$(id -g)" --rm -v $(pwd)/output:/output -t geodetischeinfrastructuur/validate-transformations:latest python /app/validate.py /app/validate_ETRS89andRDNAP.txt /output/validate-output.csv

Or by running the Python script directly.

cd validate/
uv sync # setuppython  environment with uv
direnv allow # only on installation, every subsequent opening of the workspace will activate the uv managed env, see "direnv config" section in this readme
../configure-proj.sh $(python -c 'import pyproj;print(pyproj.datadir.get_data_dir());') ../sql ../grids/nl_nsgi # note configure-proj.sh can only be run once since the sql commands will fail if applied multiple times
python validate.py validate_ETRS89andRDNAP.txt ../output/validate-output.csv

When the validation result is OK output (stdout) is:

validation result: OK
message: all points transformed and validated succesfully, output saved in output/validate-output.csv

When the validation result is FAILED output (stderr) is:

validation result: FAILED
message: accurate transformation of one or more points failed (242), invalid points saved in /output/validate-output.invalid.csv, all points saved in /output/validate-output.csv

direnv config

Repository also contains a .envrc config file, which automatically activates the uv managed virtual environment. See the direnv wiki for how to set this up.

LICENSE

The SQL used in this repository is licensed under a CC-BY license.

All other code in this repository is licensed under the MIT license.

About

Altered proj.db containing NSGI defined transformations

Resources

License

CC-BY-4.0, MIT licenses found

Licenses found

CC-BY-4.0
LICENSE
MIT
LICENSE-CODE

Stars

Watchers

Forks

Packages