Hi,

depending on the parameters you defined in spatial_ref_sys, PostGIS decides how to process the transformation, see https://blog.cleverelephant.ca/2019/02/proj4-postgis.html
Try to define proj4text only:

insert into public.spatial_ref_sys (srid,proj4text)
select 93004,proj4text from spatial_ref_sys where srid =3004;
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= +units=m +no_defs' where srid =93004; Florian

Am 16.12.2021 um 10:57 schrieb andy:
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

_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

--
CYBERTEC PostgreSQL International GmbH
Römerstraße 19, A-2752 Wöllersdorf
Web:https://www.cybertec-postgresql.com
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to