获取不规则多边形的缓冲区(python)

import geopandas as gpd
d:\ANACONDA\envs\ox\lib\site-packages\geopandas\_compat.py:111: UserWarning: The Shapely GEOS version (3.10.2-CAPI-1.16.0) is incompatible with the GEOS version PyGEOS was compiled with (3.10.1-CAPI-1.16.0). Conversions between both will be slow.
  warnings.warn(

输入数据并投影

jingkai_polygon  = gpd.read_file(r'D:/gis_ex10/new_database/控制边界/行政边界_三环.shp')
jingkai_polygon = jingkai_polygon.to_crs("EPSG:2362")  #地理坐标系转投影坐标系
jingkai_polygon.plot()
<AxesSubplot:>


png

jingkai_polygon.crs
<Derived Projected CRS: EPSG:2362>
Name: Xian 1980 / 3-degree Gauss-Kruger zone 38
Axis Info [cartesian]:
- X[north]: Northing (metre)
- Y[east]: Easting (metre)
Area of Use:
- name: China - onshore between 112°30'E and 115°30'E.
- bounds: (112.5, 21.52, 115.5, 45.45)
Coordinate Operation:
- name: 3-degree Gauss-Kruger zone 38
- method: Transverse Mercator
Datum: Xian 1980
- Ellipsoid: IAG 1975
- Prime Meridian: Greenwich

获取质心和边界信息

gdf = jingkai_polygon
gdf["centroid"] = gdf.centroid  #取质心
gdf["boundary"] = gdf.boundary  #获取边界
gdf["boundary"].plot()
<AxesSubplot:>


png

缓冲区

gdf["buffered"] = gdf.buffer(2000)
gdf["buffered"].plot()
<AxesSubplot:>


png

可视化

ax = gdf["buffered"].plot(alpha=.5,figsize = (12,15))  # saving the first plot as an axis and setting alpha (transparency) to 0.5

gdf["boundary"].plot(ax=ax, color="white", linewidth=.5) 
gdf["centroid"].plot(ax=ax, color="red", alpha=.5,markersize = 100)  # passing the first plot as an axis to the second
<AxesSubplot:>


png


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值