I have a shapefile file of the "cadastre" of Spain, I use the following command in Linux to get the sql file to next insert in database with postgis (shp2pgsql -s 900913 PARCELA.SHP> PARCELA.sql), but next to the insert, the polygons appear in Africa and not in Spain, he Observed that the projection is ETRS89 / UTM zone 30N, but I work with projection 900913, how can I transform the shapefile projection to 900913??

  • There is nothing such as 900913. You should be looking at EPSG:3857 – Devdatta Tengshe Mar 22 '17 at 11:05
  • I have also tested with 3857 and I have not gotten it either, but I do use the geom field as geometry (MultiPolygon, 900913) – josemi Mar 22 '17 at 11:12

I'm assuming that your input data is EPSG:25830.

What you should do is to first load that data in it's native CRS. This can be done by a command where you specify the native CRS, like this:

shp2pgsql -s 25830 PARCELA.SHP> PARCELA.sql

Run this Script to get the Data in your Database.

Once your Data is in the PostGIS database, then you can use the Spatial Functionality to Transform the coordinates into your required CRS.

You want to transform it to WebMercator, whose EPSG Code is 3857.

You could do this by a command like:

Select ST_Transform(geom, 3857) from table;

If you so wish, save these transformed Geometry to a different table.


Or in one step, following docummentation:

root@mapa:/var/log# shp2pgsql 
RELEASE: 2.2.1 (r14555) 
USAGE: shp2pgsql [<options>] <shapefile> [[<schema>.]<table>] OPTIONS:
   -s [<from>:]<srid> Set the SRID field. Defaults to 0.
      Optionally reprojects from given SRID (cannot be used with -D). ...

So this should also work

shp2pgsql -s 25830:900913 PARCELA.SHP> PARCELA.sql

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.