Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nc_dittt_RANC15.tif and nc_dittt_gr3dncI08.tif grids #99

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
cd grid_tools
pyflakes3 *.py
wget https://github.com/OSGeo/proj-datumgrid/raw/master/north-america/ntv2_0.gsb
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/ntv2_to_gtiff.py --copyright "Derived from work by Natural Resources Canada. Open Government Licence - Canada" --source-crs EPSG:4267 --target-crs EPSG:4269 $PWD/ntv2_0.gsb $PWD/ca_nrc_ntv2_0.tif
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/ca_nrc_ntv2_0.tif
docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/ntv2_to_gtiff.py --copyright "Derived from work by Natural Resources Canada. Open Government Licence - Canada" --source-crs EPSG:4267 --target-crs EPSG:4269 $PWD/ntv2_0.gsb $PWD/ca_nrc_ntv2_0.tif
docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/ca_nrc_ntv2_0.tif
wget https://github.com/OSGeo/proj-datumgrid/raw/master/egm96_15.gtx
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/vertoffset_grid_to_gtiff.py --type GEOGRAPHIC_TO_VERTICAL --parameter-name geoid_undulation --source-crs EPSG:4326 --target-crs EPSG:5773 --copyright "Public Domain. Derived from work from NGA" $PWD/egm96_15.gtx $PWD/us_nga_egm96_15.tif
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/us_nga_egm96_15.tif
docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/vertoffset_grid_to_gtiff.py --type GEOGRAPHIC_TO_VERTICAL --parameter-name geoid_undulation --source-crs EPSG:4326 --target-crs EPSG:5773 --copyright "Public Domain. Derived from work from NGA" $PWD/egm96_15.gtx $PWD/us_nga_egm96_15.tif
docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/us_nga_egm96_15.tif
cd ..
./travis/test.sh
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ install:
- cd grid_tools
- pyflakes3 *.py
- wget https://github.com/OSGeo/proj-datumgrid/raw/master/north-america/ntv2_0.gsb
- docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/ntv2_to_gtiff.py --copyright "Derived from work by Natural Resources Canada. Open Government Licence - Canada" --source-crs EPSG:4267 --target-crs EPSG:4269 $PWD/ntv2_0.gsb $PWD/ca_nrc_ntv2_0.tif
- docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/ca_nrc_ntv2_0.tif
- docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/ntv2_to_gtiff.py --copyright "Derived from work by Natural Resources Canada. Open Government Licence - Canada" --source-crs EPSG:4267 --target-crs EPSG:4269 $PWD/ntv2_0.gsb $PWD/ca_nrc_ntv2_0.tif
- docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/ca_nrc_ntv2_0.tif
- wget https://github.com/OSGeo/proj-datumgrid/raw/master/egm96_15.gtx
- docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/vertoffset_grid_to_gtiff.py --type GEOGRAPHIC_TO_VERTICAL --parameter-name geoid_undulation --source-crs EPSG:4326 --target-crs EPSG:5773 --copyright "Public Domain. Derived from work from NGA" $PWD/egm96_15.gtx $PWD/us_nga_egm96_15.tif
- docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/us_nga_egm96_15.tif
- docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/vertoffset_grid_to_gtiff.py --type GEOGRAPHIC_TO_VERTICAL --parameter-name geoid_undulation --source-crs EPSG:4326 --target-crs EPSG:5773 --copyright "Public Domain. Derived from work from NGA" $PWD/egm96_15.gtx $PWD/us_nga_egm96_15.tif
- docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/check_gtiff_grid.py $PWD/us_nga_egm96_15.tif
- cd ..
# Travis build directory includes /build/, which is a pattern we exclude
# in our 'make dist' target...
Expand Down
2 changes: 2 additions & 0 deletions copyright_and_licenses.csv
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ NKG,Nordic Geodetic Commission,CC-BY-4.0,,
nc_dittt_gr3dnc01b.tif,Gouvernement de Nouvelle Calédonie - DITTT,Open License France - https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf,,
nc_dittt_gr3dnc02b.tif,Gouvernement de Nouvelle Calédonie - DITTT,Open License France - https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf,,
nc_dittt_gr3dnc03a.tif,Gouvernement de Nouvelle Calédonie - DITTT,Open License France - https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf,,
nc_dittt_gr3dncI08.tif,Gouvernement de Nouvelle Calédonie - DITTT,Open License France - https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf,1.14,
nc_dittt_Ranc08_Circe.tif,Gouvernement de Nouvelle Calédonie - DITTT,Open License France - https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf,,
nc_dittt_RANC15.tif,Gouvernement de Nouvelle Calédonie - DITTT,Open License France - https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf,1.14,
nc_dittt_README.txt,Disclaimed,Public domain,,
nl_nsgi_naptrans2018.tif,Nederlandse Samenwerking Geodetische Infrastructuur (NSGI),CC-BY-4.0,,1.10
nl_nsgi_nlgeo2018.tif,Nederlandse Samenwerking Geodetische Infrastructuur (NSGI),CC-BY-4.0,,
Expand Down
141 changes: 141 additions & 0 deletions nc_dittt/convert_gr3dncI08.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#!/usr/bin/env python
###############################################################################
# $Id$
#
# Project: PROJ
# Purpose: Convert New Caledonia geocentric gr3dncI08.tac grid
# Author: Even Rouault <even.rouault at spatialys.com>
#
###############################################################################
# Copyright (c) 2019, Even Rouault <even.rouault at spatialys.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
###############################################################################

from osgeo import gdal
from osgeo import osr
import datetime
import struct

with open('gr3dncI08.tac', 'rt') as f:
count_val_rows = 0
line_no = 0
for l in f.readlines():
if l[-1] == '\n':
l = l[0:-1]
if l[-1] == '\r':
l = l[0:-1]
if not l:
continue
if line_no == 0:
tokens = []
for t in l.split(' '):
if t:
tokens.append(t)
assert len(tokens) >= 13
minx = float(tokens[0])
maxx = float(tokens[1])
miny = float(tokens[2])
maxy = float(tokens[3])
resx = float(tokens[4])
resy = float(tokens[5])
assert minx < maxx
assert miny < maxy
assert resx > 0
assert resy > 0
cols = 1 + (maxx - minx) / resx
assert cols - int(cols + 0.5) < 1e-10
cols = int(cols + 0.5)
rows = 1 + (maxy - miny) / resy
assert rows - int(rows + 0.5) < 1e-10
rows = int(rows + 0.5)
ds = gdal.GetDriverByName('GTiff').Create(
'/vsimem/gr3dncI08.tif', cols, rows, 3, gdal.GDT_Float32)
ds.SetMetadataItem(
'TIFFTAG_COPYRIGHT', 'Derived from work by Service Topographique, DITTT, Government of New Caledonia. Open License https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf')
ds.SetMetadataItem('TIFFTAG_IMAGEDESCRIPTION',
'Geocentric translation from RGNC91-93 (EPSG:4906) to RGNC15 (EPSG:10308). Converted from gr3dncI08.mnt')
datetime = datetime.date.today().strftime("%Y:%m:%d %H:%M:%S")
ds.SetMetadataItem('TIFFTAG_DATETIME', datetime)
ds.SetMetadataItem('AREA_OR_POINT', 'Point')
ds.SetMetadataItem('TYPE', 'GEOCENTRIC_TRANSLATION')
ds.SetMetadataItem('area_of_use', 'New Caledonia')
ds.SetMetadataItem('source_crs_wkt', """GEODCRS["RGNC91-93",
DATUM["Reseau Geodesique de Nouvelle Caledonie 91-93",
ELLIPSOID["GRS 1980",6378137,298.257222101,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[Cartesian,3],
AXIS["(X)",geocentricX,
ORDER[1],
LENGTHUNIT["metre",1]],
AXIS["(Y)",geocentricY,
ORDER[2],
LENGTHUNIT["metre",1]],
AXIS["(Z)",geocentricZ,
ORDER[3],
LENGTHUNIT["metre",1]],
USAGE[
SCOPE["Geodesy."],
AREA["New Caledonia - onshore and offshore. Isle de Pins, Loyalty Islands, Huon Islands, Belep archipelago, Chesterfield Islands, and Walpole."],
BBOX[-26.45,156.25,-14.83,174.28]],
ID["EPSG",4906]]""")
ds.SetMetadataItem('target_crs_epsg_code', '10308')
ds.SetGeoTransform(
[minx - resx/2, resx, 0, maxy + resy/2, 0, -resy])
ds.GetRasterBand(1).SetUnitType('metre')
ds.GetRasterBand(1).SetDescription('x_translation')
ds.GetRasterBand(2).SetUnitType('metre')
ds.GetRasterBand(2).SetDescription('y_translation')
ds.GetRasterBand(3).SetUnitType('metre')
ds.GetRasterBand(3).SetDescription('z_translation')
sr = osr.SpatialReference()
sr.ImportFromEPSG(10310)
ds.SetProjection(sr.ExportToWkt())
else:
tokens = []
for t in l.split(' '):
if t:
tokens.append(t)
assert len(tokens) == 6
lon = float(tokens[0])
lat = float(tokens[1])
dx = float(tokens[2])
dy = float(tokens[3])
dz = float(tokens[4])
ix = (line_no - 1) % cols
iy = (line_no - 1) // cols
assert abs(lon - (minx + ix * resx)
) < 1e-10, (line_no, lon, minx + ix * resx)
assert abs(lat - (miny + iy * resy)
) < 1e-10, (line_no, lat, miny + iy * resy)
ds.GetRasterBand(1).WriteRaster(
ix, rows - iy - 1, 1, 1, struct.pack('f', dx))
ds.GetRasterBand(2).WriteRaster(
ix, rows - iy - 1, 1, 1, struct.pack('f', dy))
ds.GetRasterBand(3).WriteRaster(
ix, rows - iy - 1, 1, 1, struct.pack('f', dz))
count_val_rows += 1

line_no += 1

assert count_val_rows == rows * cols
gdal.GetDriverByName('GTiff').CreateCopy('gr3dncI08.tif', ds, options=[
'COMPRESS=DEFLATE', 'PREDICTOR=3', 'INTERLEAVE=BAND'])
Binary file added nc_dittt/nc_dittt_RANC15.tif
Binary file not shown.
18 changes: 18 additions & 0 deletions nc_dittt/nc_dittt_README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ from [Gouvernement de la Nouvelle-Calédonie – DITTT](https://dittt.gouv.nc/ci

* nc_dittt_gr3dnc03a.tif

### New Caledonia - Noumea: RGNC91-93 (EPSG:4906) to RGNC15 (EPSG:10308) (using Geocentric correction)

*Source*: Gouvernement de la Nouvelle-Calédonie – DITTT](https://dittt.gouv.nc/circe-pour-la-nouvelle-caledonie)
*Format*: GeoTIFF converted from .mnt file with convert_gr3dncI08.py
*License*: [License Ouverte (in French)](https://www.etalab.gouv.fr/wp-content/uploads/2017/04/ETALAB-Licence-Ouverte-v2.0.pdf) / [Open License (English translation)](https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf)
*Used by*: EPSG:10322

* nc_dittt_gr3dncI08.tif

### New Caledonia - RGNC91-93 (EPSG:4907) to NGNC08 height (EPSG:9351) (geoid model)

*Source*: Gouvernement de la Nouvelle-Calédonie – DITTT](https://dittt.gouv.nc/circe-pour-la-nouvelle-caledonie)
Expand All @@ -40,3 +49,12 @@ from [Gouvernement de la Nouvelle-Calédonie – DITTT](https://dittt.gouv.nc/ci
*Used by*: [EPSG:9352 Transformation](https://www.epsg-registry.org/export.htm?gml=urn:ogc:def:coordinateOperation:EPSG::9352)

* nc_dittt_Ranc08_Circe.tif

### New Caledonia - RGNC15 (EPSG:10311) to NGNC08 height (EPSG:9351) (geoid model)

*Source*: Gouvernement de la Nouvelle-Calédonie – DITTT](https://dittt.gouv.nc/circe-pour-la-nouvelle-caledonie)
*Format*: GeoTIFF converted from .mnt file with vertoffset_grid_to_gtiff.py
*License*: [License Ouverte (in French)](https://www.etalab.gouv.fr/wp-content/uploads/2017/04/ETALAB-Licence-Ouverte-v2.0.pdf) / [Open License (English translation)](https://www.etalab.gouv.fr/wp-content/uploads/2014/05/Open_Licence.pdf)
*Used by*: EPSG:10319

* nc_dittt_RANC15.tif
Binary file added nc_dittt/nc_dittt_gr3dncI08.tif
Binary file not shown.
4 changes: 2 additions & 2 deletions travis/check_new_grids.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ for f in $FILES; do
esac

echo "Checking $f"
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest gdalinfo -mm $PWD/$f
docker run --rm -v /home:/home osgeo/gdal:alpine-normal-latest python3 $PWD/grid_tools/check_gtiff_grid.py $PWD/$f
docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest gdalinfo -mm $PWD/$f
docker run --rm -v /home:/home ghcr.io/osgeo/gdal:alpine-normal-latest python3 $PWD/grid_tools/check_gtiff_grid.py $PWD/$f
done
2 changes: 2 additions & 0 deletions travis/expected_main.lst
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ mx_inegi_README.txt
nc_dittt_gr3dnc01b.tif
nc_dittt_gr3dnc02b.tif
nc_dittt_gr3dnc03a.tif
nc_dittt_gr3dncI08.tif
nc_dittt_Ranc08_Circe.tif
nc_dittt_RANC15.tif
nc_dittt_README.txt
NKG
nl_nsgi_nlgeo2018.tif
Expand Down