我具有以下GeoSeries:
print(zambia_grid)
voltage_kV, geometry, buffer_value
88.0, MULTILINESTRING ((662448.559 8288872.590, 6625..., 660.0
132.0, MULTILINESTRING ((662368.932 8288816.909, 6623..., 142.0
220.0, MULTILINESTRING ((632159.980 8609158.729, 6321..., 990.0
330.0, MULTILINESTRING ((662612.310 8288970.288, 6626..., 220.0
我已经尝试创建缓冲区:
zambia_grid_buffer = zambia_grid.buffer(distance = zambia_grid['buffer_value'])
但是,当我尝试绘制它时,出现以下错误:
'多边形'对象不可下标
...在大熊猫中可能有不同的缓冲区吗?
[从GeoPandas版本0.5开始,您应该能够将buffer
参数的一系列值数组传递给distance
,以具有可变的缓冲区大小。
使用内置国家/地区数据集作为虚拟示例:
>>> df = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
>>> df
pop_est continent name iso_a3 gdp_md_est geometry
0 920938 Oceania Fiji FJI 8374.0 MULTIPOLYGON (((180.00000 -16.06713, 180.00000...
1 53950935 Africa Tanzania TZA 150600.0 POLYGON ((33.90371 -0.95000, 34.07262 -1.05982...
2 603253 Africa W. Sahara ESH 906.5 POLYGON ((-8.66559 27.65643, -8.66512 27.58948...
3 35623680 North America Canada CAN 1674000.0 MULTIPOLYGON (((-122.84000 49.00000, -122.9742...
.. ... ... ... ... ...
>>> df.buffer(distance=df['pop_est'])
0 POLYGON ((-920362.560 -15501.816, -921118.000 ...
1 POLYGON ((-1110993.428 53939492.982, 4253453.0...
2 POLYGON ((-8.666 603280.656, 58859.799 600401....
3 POLYGON ((-35623475.484 26100.474, -35623805.6...
...