1

I have a Point

RW     HW     EPSG
3011.65;341146.38;31256

which ST_Transform transforms into projection EPSG=4326, Lat;Lon 48.2086988651298;16.3686458354975

However, when using http://cs2cs.mygeodata.eu/ and checking with Google Maps and openstreetmap, the actual result should be 48.2087130847;16.3726546685;

This is much to inaccurate.

Am I doing sthg wrong when using Transform?

EDIT1: That's the way I use it:

select ST_Y(a.b), ST_X(a.b) from
  (select ST_Transform(ST_SetSRID(ST_MakePoint(3011.65, 341146.38), 31256), 4326) as b) as a
2
  • Please include the statement you are using to pass the point to ST_Transform()
    – kttii
    Jul 28, 2016 at 20:20
  • @kttii updated the questions with selectable example
    – JohnDoe
    Jul 28, 2016 at 20:39

3 Answers 3

3

It looks like PostGIS is performing some geographic/datum transformation because the output values aren't just the MGI Austria values unprojected into MGI latitude-longitude values (48.209213766 16.37385929).

I checked EPSG::1618 and EPSG::5891 but neither matched exactly. what you're getting from the mygeodata website. EPSG::1618, MGI to WGS 1984 (3) gave closer results. The EPSG::5891 transformation uses the NTv2 grid, AT_GIS.gsb.

It's possible the underlying PROJ.4 version doesn't have the NTv2 grid file (and the mygeodata doesn't either) or that the PROJ.4 definitions associated with MGI-based PCS haven't been updated to use one of the more recent transformations.

There's some information about it in the ST_Transform documentation.

2
  • When I perform the translation on the mygeodata - site it uses this paramters for Proj.4:, SRID=31256: +proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs whereas PostGIS has stored "+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +datum=hermannskogel +units=m +no_defs " in column proj4text.
    – JohnDoe
    Jul 29, 2016 at 6:04
  • That's epsg::1618.
    – mkennedy
    Jul 29, 2016 at 6:07
3

You are using ST_Makepoint which is expecting Lat Long values. To convert your 31256 SRID point to 4326 SRID you need to use ST_Point, set the SRID with ST_SetSRID and then transform it with ST_Transform in PostGIS 2.2.2:

SELECT ST_y(a.b) , st_x(a.b)
FROM (
    SELECT ST_Transform(ST_SetSRID(ST_Point(3011.65,341146.38),31256),4326) as b) as a

and the result is:

48.20871308466652 16.372654668537162

and my values for SRID 4326 and 31256 are:

    srid    auth_name   auth_srid   srtext  proj4text
    4326    EPSG    4326    GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]    
+proj=longlat +datum=WGS84 +no_defs 
    31256   EPSG    31256   PROJCS["MGI / Austria GK East",GEOGCS["MGI",DATUM["Militar_Geographische_Institute",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[577.326,90.129,463.919,5.137,1.474,5.297,2.4232],AUTHORITY["EPSG","6312"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4312"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",16.33333333333333],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",-5000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","31256"]]   
+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +datum=hermannskogel +units=m +no_defs 
10
  • That's strange, your select seems to give the correct answer while mine doesn't. SELECT PostGIS_full_version(); gives "POSTGIS="2.2.2 r14797" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.1, released 2013/08/26" LIBXML="2.9.1" LIBJSON="0.11.99" (core procs from "2.2.1 r14555" need upgrade) RASTER (raster procs from "2.2.1 r14555" need upgrad (...)"
    – JohnDoe
    Jul 28, 2016 at 20:44
  • use ST_Point the way I am for now rather than ST_MakePoint
    – kttii
    Jul 28, 2016 at 20:47
  • Tried that, it delivers the same (~wrong) result
    – JohnDoe
    Jul 28, 2016 at 20:47
  • updated answer... ST_MakePoint() is expecting Lat/Long
    – kttii
    Jul 28, 2016 at 20:49
  • @JohnDoe Updated my select statement to use your values
    – kttii
    Jul 28, 2016 at 20:53
0

I had the same problem. What I did was:

First:

DELETE FROM spatial_ref_sys WHERE auth_srid = 31256;

Then (According to http://spatialreference.org/ref/epsg/mgi-austria-gk-east/postgis/):

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext) values ( 31256, 'EPSG', 31256, '+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=0 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs ', 'PROJCS["MGI / Austria GK East",GEOGCS["MGI",DATUM["Militar_Geographische_Institute",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[577.326,90.129,463.919,5.137,1.474,5.297,2.4232],AUTHORITY["EPSG","6312"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4312"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",16.33333333333333],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",-5000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","31256"]]');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.