【问题标题】:Geojson to shapefile convertion using shapefile library使用 shapefile 库将 Geojson 转换为 shapefile
【发布时间】:2018-11-29 21:09:34
【问题描述】:

如果shapefile 仅包含多边形,我知道我可以从geojson 创建shapefile,但如果有MultiPolygon,我会收到以下错误:

返回[min(x), min(y), max(x), max(y)]

TypeError: 'list' 和 'float' 的实例之间不支持'

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())

【问题讨论】:

    标签: python geojson shapefile


    【解决方案1】:

    经过一番搜索,我发现在一个多多边形中

    [ 多边形_0, 多边形_1, . . ]

    只有 polygon_0 是实际的多边形,其余的多边形是 。 就我而言,我根本不需要孔,所以我基本上将多面体转换为多边形。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-06
      • 1970-01-01
      • 2017-08-24
      • 1970-01-01
      • 1970-01-01
      • 2019-07-26
      • 1970-01-01
      • 2020-12-10
      相关资源
      最近更新 更多