2

I got sample shapefiles with the following *prj file content:

PROJCS["RGF93_Lambert_93",GEOGCS["GCS_RGF_1993",DATUM["D_RGF_1993",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",700000.0],PARAMETER["False_Northing",6600000.0],PARAMETER["Central_Meridian",3.0],PARAMETER["Standard_Parallel_1",44.0],PARAMETER["Standard_Parallel_2",49.0],PARAMETER["Latitude_Of_Origin",46.5],UNIT["Meter",1.0]]

Trying to convert the projection using the shp2pgsql command shp2pgsql -s 4326 kept the original projection and didn't convert it as requested.

I also check spatial_ref_sys table srtext field for similar known projection unsuccessfully.

How can I convert it to WGS 84 projection?

3 Answers 3

8

The shp2pgsql tool is used to load data into PostGIS. It is not meant for transforming projections. The -s flag of the command just tells shp2pgsql the SRID of your source data. It doesn't transform the projection at all. You can reproject it before you load it to PostGIS or after.

To transform the projection before you load it to PostGIS, you can use GIS tools like QGIS or GDAL.

To change the projection after loading the data into PostGIS, you can use the ST_Transform command.

Btw, you have to give the shp2pgsql tool the shape file's actual projection. According to Spatialreference.org, your shape file's SRID is 2154. You might want to import it properly this time, using -s 2154 instead of -s 4326 and then perform the ST_Transform on PostGIS.

Of the two options, I think it would be simpler to convert the file before loading it to PostGIS. That way, you won't have to mess around with the spatial database much.


On Identifying your shape file's projection

Stumbled upon prj2EPSG from after reading this thread. Pasted your definition on it and got the following results:

  • 2154 - RGF93 / Lambert-93
  • 3944 - RGF93 / CC44
  • 3949 - RGF93 / CC49

You might want to investigate those three.

9
  • thanks for your assistance. I cannot run the st_transform since the original projection is unknown to postgis.
    – OLS
    Sep 20, 2012 at 21:29
  • updated my answer. You might want to import it properly this time.
    – R.K.
    Sep 20, 2012 at 21:45
  • 1. how can I dig from the prj file the projection name / SRID? 2. I ran shp2pgsql -s 104107 [file.shp] > [file.sql] and than tried to upload it to db. It fails. stating invalid SRID
    – OLS
    Sep 20, 2012 at 21:54
  • I just looked at the data you posted. Yours has GCS_RGF_1993. I searched it on Google and then I got a result at spatialreference.org
    – R.K.
    Sep 20, 2012 at 21:56
  • 1
    From at least PostGIS v2.0.0 you can specify a source and a target SRID in shp2pgsql command line tool (somehow not in the GUI yet). Just run "shp2pgsql -?" to display your version and options. It says: "-s [<from>:]<srid> Set the SRID field. Defaults to 0. Optionally reprojects from given SRID (cannot be used with -D)."
    – der Michi
    Jul 18, 2013 at 12:13
4

as R.K. already told you there are lots of free tools like qgis. If you just simple want to convert your shape-files to a different projection and you use windows give ogr2gui (http://www.ogr2gui.ca/en/index.php) a try (portable, just download: http://www.ogr2gui.ca/0.6/ogr2gui_0.6.zip and http://www.ogr2gui.ca/0.6/ogr2gui_dll.zip, extract all into a folder or onto usb stick and start excuteable: enter image description here

2
  • 1
    I saved the layer from qgis to the desired projection and it saved it correctly. What's the original projection? I'm in unix, can perform the ogr2ogr manually?
    – OLS
    Sep 20, 2012 at 21:39
  • seems like R.K. has already answered this too
    – Kurt
    Sep 21, 2012 at 6:52
1

I've used this online converter successfully:

http://converter.mygeodata.eu/vector

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.