I have a large radar image (1.1GB) from Sentinel-1 and I need to make it smaller so that I can process it without my memory crashing. Using QGIS I generated the command to mask an image based on a shapefile using Raster > Extraction > Clipper.

The command was gdalwarp -q -cutline my_shapefile -tr 0.000107418644212 0.000107418644212 -of GTiff my_sourceTIF my_destinationTIF.

When I run this command in my OSX terminal it generates a new TIF image. But when I open it in QGIS, the image covers the same area as before except the whole thing is now black.

  • 1
    Are you sure that your source raster and shapefile align if On-The-Fly-reprojection is turned OFF? – AndreJ Apr 11 '17 at 5:21
  • Resolution maybe? Are you in lat/lon or meters? – julsbreakdown Apr 11 '17 at 8:25
  • @AndreJ I am not familiar with on the fly reprojection, but in QGIS the shapefile is in the location that I want it to be in relation to the raster. – user92395 Apr 11 '17 at 20:38

Read the documentation http://www.gdal.org/gdalwarp.html especially from here:

Polygon cutlines may be used as a mask to restrict the area of the destination file that may be updated, including blending. If the OGR layer containing the cutline features has no explicit SRS, the cutline features must be in the SRS of the destination file. When writing to a not yet existing target dataset, its extent will be the one of the original raster unless -te or -crop_to_cutline are specified.

QGIS seems to create a command that does not adjust the extents of the output. Adding -crop_to_cutline should help:

-crop_to_cutline: (GDAL >= 1.8.0) Crop the extent of the target dataset to the extent of the cutline.

What is the bit depth of your Sentinel-1 image? High bit depth images appear often black on screen if all the data are near the lower end of the range. Adjusting image properties with QGIS by applying a min-max stretch helps in this case.

  • The -crop_to_cutline solved the clipping problem, but it is still all black. Could you explain more about the min-max stretch? – user92395 Apr 11 '17 at 20:51
  • I found the min-max stretch option and that was already applied. The solution to the blackness was to compress the image as described in the answers here: gis.stackexchange.com/questions/144962/… – user92395 Apr 12 '17 at 0:46
  • Compression with "deflate" should not have any effect on the pixel values but good that you can see the image now even I wonder why. – user30184 Apr 12 '17 at 4:04

Your Answer

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

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