Convert geopandas shapely polygon to geojson

前端 未结 6 1909
猫巷女王i
猫巷女王i 2021-02-18 19:24

I created a circle using geopandas and it returned a shapely polygon:

POLYGON: ((...))

I want this same polygon as a geojson object. I ran acr

6条回答
  •  误落风尘
    2021-02-18 19:46

    You can also use PyShp

    import shapefile
    
    with shapefile.Reader("shapefile.shp") as shp:
        geojson_data = shp.__geo_interface__
    

    or

    geojson_data = shapefile.Reader("shapefile.shp").__geo_interface__
    

    example usage:

    >>> geojson_data["type"]
    
    'MultiPolygon'
    

提交回复
热议问题