Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I got sample shape files 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?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
thanks for your assistance. I cannot run the st_transform since the original projection is unknown to postgis. –  OLS Sep 20 '12 at 21:29
    
updated my answer. You might want to import it properly this time. –  R.K. Sep 20 '12 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 '12 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 '12 at 21:56
    
Just found a new tool. You might want to check my answer again. –  R.K. Sep 20 '12 at 22:11

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

share|improve this answer
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 '12 at 21:39
    
seems like R.K. has already answered this too –  Kurt Sep 21 '12 at 6:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.