I am trying to clip a raster .tif file with a polygon shapefile using gdalwarp. For the majority of the extent, the results are as expected. But there are several gaps where portions of the raster that appear to clearly overlap the polygon are omitted from the clip. In these areas, raster cells that appear to fall entirely within the polygon boundary are still omitted. Both input files are in the same projected coordinate system.

The top image shows the gdalwarp clip results in black over the input raster in orange and clipping polygon layer in blue.

enter image description here The bottom image shows the same layers with an additional layer in pink. The additional layer was produced using the Extract by Mask tool in ArcMap, which produces the results that I would have expected from gdalwarp. I am looking for an open source solution though. enter image description here

I have tried both of the following commands:


gdalwarp -of GTiff -tr 30.0 -30.0 -tap -cutline "C:\\Users...buff2.shp" "C:\\Users...tiled_p.tif" "C:\\Users...4i.tif"


gdalwarp -of GTiff -cutline "C:\\Users...buff2.shp" -crop_to_cutline "C:\\Users...tiled_p.tif" "C:\\Users...4i.tif"

I am on a Windows 10 computer. Unfortunately I cannot reproduce the datasets to share.

Are there ideas for why this might be happening and how I might fix this using gdal or other open-source tools?

  • 1
    Double check the projection of both your files. The fact the black pixels in images are offset slightly from the orange pixels tells me they probably aren't exactly the same. – scabecks Feb 18 '18 at 3:50
  • Both files have the same projection (EPSG: 5070). I reprojected the output raster to EPSG 5070 too, just to make sure it was consistent, but it still appears offset when rendered and still has the unexpected results. – THopGro Feb 18 '18 at 4:16
  • Are both the pixel size and extents the same between the two rasters as well? – scabecks Feb 18 '18 at 5:21
  • The pixel sizes are the same between the two rasters. I tried manually setting the extent of the output raster to match the input raster, but that did not affect the results. – THopGro Feb 18 '18 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.