Created
August 17, 2018 08:17
-
-
Save pierdom/20a1b90f9e104dd733d1c7f26cc1eb13 to your computer and use it in GitHub Desktop.
[Convert a shapely Polygon to GeoJson using GeoPandas] from: https://stackoverflow.com/questions/51486454/convert-geopandas-shapely-polygon-to-geojson #python #datascience #gis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from shapely.geometry import Point | |
In [2]: import geopandas as gpd | |
In [3]: shapely_polygon = Polygon([(0, 0), (0, 1), (1, 0)]) | |
In [4]: gpd.GeoSeries([shapely_polygon]).__geo_interface__ | |
Out[4]: | |
{'bbox': (0.0, 0.0, 1.0, 1.0), | |
'features': [{'bbox': (0.0, 0.0, 1.0, 1.0), | |
'geometry': {'coordinates': (((0.0, 0.0), | |
(0.0, 1.0), | |
(1.0, 0.0), | |
(0.0, 0.0)),), | |
'type': 'Polygon'}, | |
'id': '0', | |
'properties': {}, | |
'type': 'Feature'}], | |
'type': 'FeatureCollection'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output