Search code examples
geolocationgeospatialpostgisgeo

Polygon another location


Looking google maps have located 4 points and have created a polygon with them in this way

insert into dummy_zip values (4,'prueba_directa','2016-04-13 08:08:15.973731','prueba_directa',1,1,100,'2016-04-13 08:08:15.973731',(SELECT ST_Transform(ST_GeomFromText('MULTIPOLYGON(((37.986504 -1.121951,37.986741 -1.121243,37.985794 -1.120792,37.985608 -1.121479,37.986504 -1.121951)))',4326),900913)));

but when displayed on the map they are in a completely different location than where they should be?


Solution

  • Swap the axis order, which should be (X Y) or (long lat).

    You can use ST_FlipCoordinates to fix any existing data.