3

I'm trying to figure out how to make some translations from UTM/ED50 to WGS84.

The reason I need to do them is that my data source's coordinates are in EPSG:23030 format, and I need to represent them in a map, currently using leaflet, which needs every coordinates to be in WGS84.

I've been using Postgis' raw sql queries to transform coordinates, as follows:

SELECT ST_AsText(ST_Transform(ST_GeomFromText('POINT(581087 4796507)', 23030), 4326));

That query returns me the following:

"POINT(-2.0013194711113 43.3151520669395)"

good coord

As I'm developing a web project using html+js and so on, I needed some library to make translations. So I found proj4js, and I can make translations as follows:

proj4.defs([
    [
        'EPSG:4326', 
        '+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees'
    ],
    [
        'EPSG:23030',
        '+title=ED50 (UTM) +proj=utm +zone=30 +ellps=intl +units=m +no_defs'
    ]
]);

var coord = proj4('EPSG:23030', 'EPSG:4326').forward([581087,4796507]);

holding coord the following coordinate:

43.315428738109816, -2.000074748128657

wrong coordinate

So the question is why am I getting different coordinates, knowing that I'm -seemingly- using the same coordinate systems to make the translation in PostGis and in Proj4js? Is there something wrong?

As far as I know, the right conversion corresponds to PostGis.

  • 1
    The PostGIS towgs84 values are the generic ones for ED50 to WGS84. A more accurate one for Spain is a 7 parameter one: -131.0,-100.3,-163.4,-1.244,-0.02,-1.144,9.39 AKA EPSG:1633. If you want to stick with a 3 parameter one, EPSG:1145, -84,-107,-120. – mkennedy Feb 5 '16 at 20:05
4

Check the proj definition stored in the spatial_ref_sys, it should be different from the one used in the proj4js definition.

For example, mine is the following: +proj=utm +zone=30 +ellps=intl +towgs84=-87,-98,-121,0,0,0,0 +units=m +no_defs

Also epsg.io gives the one with the towgs84 parameters, so I'd change the Proj4js def.

  • Query to use is select proj4text from spatial_ref_sys where srid=23030; – user30184 Feb 5 '16 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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