I used this script to crop a raster using a polygon shapefile with python gdal.Warp, but it seems it leaves many pixels with value = 1 outside the cropline
gdal.Warp(rasterOut.jp2,
rasterIn.jp2,
cutlineDSName=mask.shp,
cropToCutline=True,
dstNodata = nodata)
I can select any nodata, like 0 or np.nan, but the results doesn't change
I used this script to crop a raster using a polygon shapefile with python gdal.Warp, but it seems it leaves many pixels with value = 1 outside the cropline
gdal.Warp(rasterOut.jp2,
rasterIn.jp2,
cutlineDSName=mask.shp,
cropToCutline=True,
dstNodata = nodata)
I can select any nodata, like 0 or np.nan, but the results doesn't change
Share Improve this question asked Mar 13 at 10:37 ilFontailFonta 3014 silver badges20 bronze badges1 Answer
Reset to default 0Can you try setting stricter clipping with warpOptions=["CUTLINE_ALL_TOUCHED=TRUE"])
gdal.Warp("rasterOut.jp2", "rasterIn.jp2",
cutlineDSName="mask.shp",
cropToCutline=True,
dstNodata=nodata,
warpOptions=["CUTLINE_ALL_TOUCHED=TRUE"])