1

In GeoPandas is there any need to read in a shapefile with its coordinate reference system or is it only the exporting that requires that a coordinate reference system.

shp1= gpd.read_file(i[1],encoding='iso8859_7',crs_wkt='2100')
shp1.to_file(out,encoding='iso8859_7',crs_wkt='2100')
user10092387
  • 101
  • 1
  • 1
  • 3
  • @nmtoken You changed the question entirely with your edit. Now it looks like CRS only and not encoding which is not the case.The question is if it is needed to open with a crs that you are going to export it with anyway. – user10092387 Jul 18 '18 at 06:54
  • Please edit it back to the required question. Please do though ask the full question in the body and just a summary in the title – nmtoken Jul 18 '18 at 07:11

1 Answers1

1

Your geopandas code will not preserve crs, it'll create an empty proj file because crs_wkt is not valid. There you should specify the wkt definition of the projection, see: GeoPandas to_file() saves GeoDataFrame without coordinate system. The empty prj file may cause problem when you open your dataset in a desktop GIS.

If there is a .prj file for the input shape and you don't want to change neither encoding nor crs you should specify only the input and output file. So let's suppose you have an esri shape named my_shape, you should have my_shape.shp, my_shape.shx, my_shape.dbf and (optionally) my_shape.prj in the same folder. This case the following code is enough to preserve crs and encoding:

shp1= gpd.read_file(i[1])
shp1.to_file(out)

And the encoding and the crs will be preserved.

Zoltan
  • 7,325
  • 17
  • 27
  • I don't understand it well. Edit your answer to specify for which case you are referring to and also what is the correct way to do it. Is putting crs during the import too, the correct way or only at the exporting is needed. By the way I need it to have a specific crs when is exported. The question is if it is needed to import it to geopandas with the crs or only export it with crs that it needs. Thank you. – user10092387 Jul 18 '18 at 07:04
  • But how can i turn the crs to be in 2100 and export it so it will have '2100' when i open it in a GIS software? – user10092387 Jul 18 '18 at 14:52
  • A desktop GIS software can use the .prj file or you can set the crs for the layer in the layer properties dialog. – Zoltan Jul 19 '18 at 09:48