Monday, 4 February 2019

shapefile - Converting projection?



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?



Answer



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.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...