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??
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