I would like to add columns xmin
, xmax
, ymin
, ymax
and I take coordinates from column 'geometry'. I have exemplary dataframe with 1 records. Where is the problem?
Data:
FID_1 GODLO geometry
0 0 7.101.01.21 POLYGON ((7340000.000 5425000.000, 7340000.000...
I use, but I am getting the error:
TypeError: 'Polygon' object does not support item assignment
import geopandas as gpd
budynki = gpd.read_file('/home/gis/siatki_skorowidzowe/s7_2000/2000s7_2000.shp', rows = slice(0,1), encoding ='cp1250')
xlist = []
ylist = []
for polygon in budynki['geometry']:
for x, y in polygon.exterior.coords:
xlist.append(x)
ylist.append(y)
for x in xlist:
minx = float(min(xlist))
maxx = float(max(xlist))
for y in ylist:
miny = float(min(ylist))
maxy = float(max(ylist))
polygon['xmin'] = minx
polygon['xmax'] = maxx
polygon['ymin'] = miny
polygon['ymax'] = maxy