2

When I try to crop a raster using QGIS Clipper tool, I get the following error message: ERROR 1: Attempt to create 0x0 dataset is illegal,sizes must be larger than zero.. Why?

The code QGIS generated to perform the clip was as follows: $ gdalwarp -q -cutline <clip_mask>.shp -crop_to_cutline -of GTiff <input_raster>.tif <output_raster>.tif

The same error message is generated if I try to run the gdalwarp command by itself from the commandline.

1
  • I had the same error, but in my case, the clip_mask shapefile contained a really small polygon, much smaller than a pixel of my input raster. So I had to identify when it happened so I could prevent clipping with shapefiles masks with really small polygons. (in my case, I checked for polygons with at least 5x the area of a pixel). Problem solved here too. Thanks for your question.
    – hbobenicio
    Commented Jan 18, 2013 at 14:52

2 Answers 2

3

This error occurred because the raster and vector were not in the same projection. In this case, the vector layer had to be reprojected to match the raster CRS.

0

I had the same error, but in my case, the solution was slightly different. (I'm answering here as an alternative answer. Mine had nothing to do with rudivonstaden's answer).

The clip_mask shapefile contained a really small polygon, much smaller than a pixel of my input raster. So I had to identify when it happened so I could prevent clipping with shapefiles masks with really small polygons. (in my case, I checked for polygons with at least 5x the area of a pixel).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.