postgis / docker-postgis

Docker image for PostGIS
https://hub.docker.com/r/postgis/postgis/
MIT License
1.39k stars 466 forks source link

ST_Transform() GMM (3785) to NZMG (27200) gives incorrect results, version 13-3.3 #326

Closed captain-igloo closed 1 year ago

captain-igloo commented 1 year ago

I have a problem converting from GMM to NZMG with postgis 13-3.3. The results are out by more than 200m.

To demonstrate the problem, convert from GMM (3785) to NZMG (27200) to WGS84 (4326) and back to GMM. With version 13-3.0 the result is close to zero as expected:

docker run --name postgis-13-3.0  -e POSTGRES_PASSWORD=secret -d postgis/postgis:13-3.0

docker exec -it postgis-13-3.0 psql -U postgres

postgres=# select st_distance(ST_GeomFromText('POINT(19647272.826154 -4756256.832248)', 3785), st_transform(ST_Transform(ST_Transform(ST_GeomFromText('POINT(19647272.826154 -4756256.832248)', 3785), 27200), 4326), 3785));

    st_distance       
------------------------
 2.5104732426926237e-05
(1 row)

But the same query with version 13-3.3 returns the following incorrect result:

docker run --name postgis-13-3.3  -e POSTGRES_PASSWORD=secret -d postgis/postgis:13-3.3

docker exec -it postgis-13-3.3 psql -U postgres

postgres=# select st_distance(ST_GeomFromText('POINT(19647272.826154 -4756256.832248)', 3785), st_transform(ST_Transform(ST_Transform(ST_GeomFromText('POINT(19647272.826154 -4756256.832248)', 3785), 27200), 4326), 3785)); 

    st_distance     
--------------------
 254.48021461937208
(1 row)

I have tried "projsync --system-directory --file nzgd2kgrid0005.tif" but that did not help.

Thanks

captain-igloo commented 1 year ago

I now think this is a problem with either proj or postgis, not the docker image.