I am using GeoPandas in python and have a valid GeoDataframe of polygons.
0 POLYGON Z ((68.70999999999999 623.1 0, 35.71 6...
1 POLYGON Z ((221.33 645.02 0, 185.7 640.33 0, 1...
2 POLYGON Z ((150.3 650 0, 160.9 650 0, 150.58 6...
I want to obtain a new dataframe that has the bounding box coordinates for each row in the dataframe.
Now I am getting some odd behavior for GeoPandas.
Say I name the GeoDataFrame gdf
, then using the code:
gdf.bounds
I get the corresponding error. I have no clue what this error is supposed to mean, since I did not pass any values into the bounds
method--they were passed implicitly.
ValueError: Shape of passed values is (1, 110042), indices imply (4, 110042)
When I try:
gdf.geometry.bounds
I get the same ValueError...
However, when I do it this way, I get a valid answer:
gdf.head(10).bounds
I get
minx miny maxx maxy
0 0.00 618.15 68.71 650.00
1 169.56 640.33 221.33 650.00
2 150.30 648.64 160.90 650.00
So gdf
and gdf.head()
are not any different, yet one gives me an error and one does not. Does anyone know the correct way to get the bounding boxes corresponding to each row.