背景:栅格文件tif 和 一个保证被栅格完全覆盖的polygon(shp格式) ,使用rasterio.mask报错:ValueError: Input shapes do not overlap raster.(栅格与形状不重叠)
我用的fiona打开的polygon,代码:
def clipRasterByShapefile(src, shpdatafile, dst, nodata=0):
with fiona.open(shpdatafile, "r", crs=from_epsg(32718)) as shapefile:
features = [feature["geometry"] for feature in shapefile]
src = rasterio.open(src)
print(shapefile.crs, src.crs)
out_image, out_transform = rasterio.mask.mask(src, features,
all_touched=True,
crop=True,