0

I am currently working on the data structure of shapefile using python and geopandas, shapely, and pyshp. To minimize the total size of a shapefile, the geometry column's datatype should be float32. I've tried many times to convert flaot64 to float32 with shapely and pyshp, I can't find any way to do it. Is there any way to change the data type of geometry in a shapefile?

When I use shapely library to write 2D polygon shapefile, even though I use 2 float32 numpy arrays as input coordinates, it automatically changes polygon's datatype to float64. and pyshp also.

I googled to find the way, couldn't find any solution. Maybe because shapefile uses float64 as a default polygon data type according to ESRI shapefile Technical Description.

lyman song
  • 21
  • 3
  • Have you tried saving to shp using Geopandas (which uses Fiona for that)? – martinfleis Sep 24 '19 at 12:20
  • Is there any way to make a polygon object using fiona? I guess it only takes existing polygon(geometry) data. – lyman song Sep 25 '19 at 01:47
  • fiona saves shapely geopandas GeoDataFrame to shapefile. I am just guessing here, but it might be able to preserve type of your numpy arrays. – martinfleis Sep 25 '19 at 07:07
  • It looks like when I make a shapely Polygon object, it changes its datatype to float64 regardless of the input datatype. – lyman song Sep 27 '19 at 03:43

0 Answers0