5

I am trying to add CRS to a shapefile that I am exporting:

shp1= gpd.read_file(i[1],encoding='iso8859_7',crs_wkt='2100')
shp1.to_file(out,encoding='iso8859_7',crs_wkt='2100')

When I import it to a GIS later, it doesn't have the CRS that says in crs_wkt.

I tried to do this:

shp1=shp1.to_crs(epsg=2100)

but says:

RuntimeError: b'no arguments in initialization list'

If check for the crs it has

shp1.crs

it says:

{}
6

The to_crs function is for converting from one CRS to another. To assign a CRS to a GeoPandas object, simply assign it to the .crs attribute. For example, my_geoseries.crs = {'init' :'epsg:4326'}.

The GeoPandas documentation is quite good: http://geopandas.org/projections.html

You trigger the RuntimeError because there is no CRS to convert from, hence the 'no arguments' phrase.

  • After giving crs the way you suggested it indeed got the crs but when i exported it, and opened it in GIS it said that is missing spatial reference information.What is going on? – user10092387 Jul 19 '18 at 7:16
  • @user10092387 save your GeoDataFrame to your shapefile with to_file('your_file.shp') if you still have that problem check the .prj file that's where the projection info is, if it's not updated to the desired CRS either change it manually with a valid Proj4 dictionnary or empty it and resave your file using geopandas – Hicham Zouarhi Jul 19 '18 at 7:50
  • 1
    @HichamZouarhi i saved it with to_file but the proj file is empty. Can you tell what exactly to type for the proj4 dictionary to work? – user10092387 Jul 19 '18 at 8:05
  • @user10092387 here is an example of a projection string in a .prj file PROJCS["RGF93_Lambert_93",GEOGCS["GCS_RGF93",DATUM["D_RGF_1993",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["standard_parallel_1",49],PARAMETER["standard_parallel_2",44],PARAMETER["latitude_of_origin",46.5],PARAMETER["central_meridian",3],PARAMETER["false_easting",700000],PARAMETER["false_northing",6600000],UNIT["Meter",1]] you can download a prj file from here spatialreference.org/ref/epsg/ggrs87-greek-grid – Hicham Zouarhi Jul 19 '18 at 8:34
  • I don't get it. What should i do aside from the shp1.crs = {'init' :'epsg:2100'} to actually open it in the GIS with the assigned crs? – user10092387 Jul 19 '18 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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