Select to view content in your preferred language

Convert geometry from bounds to Polygon - GeoPandas

1224
1
Jump to solution
09-03-2022 04:40 AM
MahreenKohkar
New Contributor

I have a GeoPandas DataFrame with bounds geometry. 

import pandas as pd
import geopandas as gpd

gdf = gpd.GeoDataFrame({
                        'id': [0, 1],
                        'b': [((40.6494140625, -86.7919921875), (40.69335937...)), 
                              ((39.55078125, -93.8232421875), (39.5947265625...))]
                      })

gdf['b'][0]

Bounds(sw=SouthWest(lat=32.8271484375, lon=-96.8115234375), ne=NorthEast(lat=32.87109375, lon=-96.767578125))

print(type(gdf['b'][0]))

<class 'geolib.geohash.Bounds'>

How do I turn Bounds into Polygon geometry type? Like,

Polygon((40.6494140625, -86.7919921875), (40.69335937...)) 

 

0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor
0 Kudos
1 Reply
Luke_Pinner
MVP Regular Contributor

Answered on GIS StackExchange

0 Kudos