0

I have a Shapefile with multiple polygons. When using the following method to generate a WKT the resultant output is only the first polygon of the Shapefile. The method works fine for single polygon Shapefiles but not for a Shapefile with multiple polygons that are individual records.

from shapely import wkt
import geopandas as gpd
gpd_multipolygon = gpd.read_file("shapefile.shp")
wkt_object = wkt.dumps(gpd_multipolygon['geometry'][0])
Larry
  • 45
  • 1
  • 8

1 Answers1

0

I believe the answer is related to how the shapefile was originally generated if it was created as polygon but has multiple separate polygons (records). It would appear that when converted to WKT only the first polygon is converted and the other polygons (records) are dropped.

Update: I resolved the issue by using dissolve to aggregate all of the polygons to a single polygon record. Exported the ArcGIS feature class to a new shapefile that resulted in a multipolygon type when using geopandas as noted in the code example.

Difference between Polygon and Multpolygon are here. https://gis.stackexchange.com/questions/225368/understanding-difference-between-polygon-and-multipolygon-for-shapefiles-in-qgis

Larry
  • 45
  • 1
  • 8