我知道,如果shapefile只包含多边形,则可以从geojson创建shapefile,但如果存在MultiPolygon,则会出现以下错误:
返回最小(X),最小(Y),最大(X),最大(Y) TypeError:“列表”和“浮点”的实例之间不支持“<”**
return self.__bbox(self._shapes)方法在shapefile.py**下的应用
任何关于我如何克服这个问题的想法都将不胜感激。
提前谢谢。
import shapefile
shape_file_writer = shapefile.Writer(SHAPE_FILE_TYPE)
#example of field [field, "C", 200, 0]
shape_file_writer.fields = self.__get_shape_file_fields()
for feature in geojson_data["features"]:
if feature["geometry"]["type"] == "MultiPolygon":
continue
else:
shape_file_writer.poly(parts=feature["geometry"]["coordinates"], shapeType=5)
shape_file_writer.record(*feature["properties"].values())发布于 2018-07-04 14:25:05
经过一番搜索,我发现在一个多多边形中
polygon_0,polygon_1,.。
只有polygon_是实际多边形,其余的多边形是孔。在我的例子中,我根本不需要洞,所以我基本上把多个多边形转换成多边形。
https://stackoverflow.com/questions/50953209
复制相似问题