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 after the insert, the polygons appear in Africa and not in Spain, I note that the projection is ETRS89 / UTM zone 30N, but I work with projection EPSG:900913.

How can I transform the shapefile projection to EPSG:900913??

  • There is nothing such as 900913. You should be looking at EPSG:3857 Mar 22, 2017 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, 2017 at 11:12

2 Answers 2


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

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.


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.