[postgis-users] Not able to use properly custom projection

andy aborruso at gmail.com
Thu Dec 16 01:57:24 PST 2021


Hi,
I have a NTV2 file, and it works properly if I hardcode the parameters in
the query:

SELECT  ST_AsText(
          ST_Transform(
            ST_GeomFromText('POINT(13.335462 41.132282)',4326),3004
          )
        ) AS not_corrected,
        ST_AsText(
          ST_Transform(
            ST_GeomFromText('POINT(13.335462 41.132282)',4326),
 '+proj=tmerc +lat_0=0 +lon_0=15 +k=0.9996 +x_0=2520000
 +y_0=0 +ellps=intl
 +nadgrids=40441123_43581445_R40_F00.gsb +units=m +no_defs'
          )
        ) AS corrected;

The output is:

- POINT(2380292.276247742 4554785.392090227)
- POINT(2380294.3337390865 4554784.22045453)

If I insert it in PostGIS

-- create new record
insert into public.spatial_ref_sys (srid, auth_name, auth_srid, srtext,
proj4text) select 93004 , auth_name, auth_srid, srtext, proj4text from
spatial_ref_sys where srid = 3004;

-- update it
update spatial_ref_sys set proj4text = '+proj=tmerc +lat_0=0 +lon_0=15
+k=0.9996 +x_0=2520000 +y_0=0 +ellps=intl
+nadgrids=40441123_43581445_R40_F00.gsb +units=m +no_defs' where srid =
93004

and then I run

SELECT  ST_AsText(
          ST_Transform(
            ST_GeomFromText('POINT(13.335462 41.132282)',4326),3004
          )
        ) AS not_corrected,
        ST_AsText(
          ST_Transform(
            ST_GeomFromText('POINT(13.335462 41.132282)',4326),93004
          )
        ) AS corrected;

I obtain two equal results, as if it did not apply what was read in the
proj string in spatial_ref_sys:

- POINT(2380292.276247742 4554785.392090227)
- POINT(2380292.276247742 4554785.392090227)

I'm using PostgreSQL 13.5, compiled by Visual C++ build 1914, 64-bit, 3.1
USE_GEOS=1 USE_PROJ=1 USE_STATS=1

I can't figure out what the problem could be. Why does it work hardcoded
and not via spatial_ref_sys?

Thank you

-- 
___________________

Andrea Borruso
website: https://medium.com/tantotanto
38° 7' 48" N, 13° 21' 9" E, EPSG:4326
___________________

"cercare e saper riconoscere chi e cosa,
 in mezzo all’inferno, non è inferno,
e farlo durare, e dargli spazio"

Italo Calvino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20211216/a2ef4e08/attachment.html>


More information about the postgis-users mailing list