2

I'm working with postGIS 2.1 I have a table called 'xacementos' created with the srid: 900913. I took the points coordinates from google maps and I want to convert them to SRID:4326 to show the points in a map created over leaflet. (if a input the 900913 coordinates as geoJSON in the leaflet code the points show a little bit displaced) I'm using the function ST_Transform:

SELECT ST_AsText(ST_Transform(geom,4326)) FROM xacementos WHERE enderezo='Rua Franja 9-11';

but the coordinates that show up are not correct:

"POINT(-7.54315344075162e-005 0.000389606525237254)"

The input coordinates in the 900913 srid are "POINT(-8.397 43.3708)"

I'm newby in this postGIS stuff and I'm not sure if i'm following the right path.

Any suggestion??

1 Answer 1

4

I guess you are confused with what the different coordinates are.

EPSG:900913 (officially EPSG:3857) has an extent (worldwide) of

-20037508.34,-20037508.34,20037508.34,20037508.34

Your point (-8.397 43.3708) does not seem to be in this range (it's in portugal, right?)

This means that your point is in EPSG:4326 ("lat/lons") already.

You saying that "I took the points coordinates from google maps" confirms this to me, as google maps uses spherical mercator (EPSG:900913) internally, but it's api (and web pages) exposes all coordinates as EPSG:4326

Therefore, you should store your coordinates in PostGIS with EPSG:4326, and if this is what you need to get out there should be no need for transformations.

3
  • Yes i took the coordinates from google maps, but when i put this data into leaflet code the points are displaced (i thought it was because the projection). Should i post another question?
    – Javi Abia
    Commented Mar 6, 2014 at 10:50
  • How much offset do you have?
    – AndreJ
    Commented Mar 6, 2014 at 11:05
  • more or less 100 meters.
    – Javi Abia
    Commented Mar 6, 2014 at 11:08

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.