Geopandas:团结陆地和沿海缓冲多边形

问题描述

我想将通过gpd.buffer()方法从海岸线shapefile中创建的多边形与地块的多边形合并在一起 这两个数据集(海岸和陆地)都从www.naturalearthdata.com获取

$ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_coastline.zip
$ unzip ne_50m_coastline.zip -d coastlines
$ wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/physical/ne_50m_land.zip
$ unzip ne_50m_land.zip -d land

到目前为止我的工作流程:

import geopandas as gpd
import matplotlib.pyplot as plt

coast_shapefile = "coastlines/ne_50m_coastline.shp"
land_shapefile = "land/ne_10m_land.shp"
# read shapefiles with geopandas and specify the initial CRS (units: degree)
coast = gpd.read_file(coast_shapefile,crs={'init' :'epsg:4326'})
land = gpd.read_file(land_shapefile,crs={'init' :'epsg:4326'})
# Now create a buffer zone around the coastlines
coast_bfr = gdf.geometry.buffer(0.2)

缓冲区(coast_bfr)代表海岸线周围的多边形,并在陆地内部形成“空白区域”。我现在想将这些缓冲多边形与代表陆地的多边形结合起来。但是,geopandas的union()不起作用。

有人提示我如何实现这一目标?提前非常感谢!

解决方法

您是否研究了gdf.overlay()功能?联合(好吧,cascaded_union和unary_union)是shapely处理的元素操作,但是整个形状集由overlay operations处理。