This question already has an answer here:

Clipping a raster using a polygon with GDAL is easy - that is if you want to discard the data outside the polygon and keep what's inside it.
(Using gdalwarp -cutline)

I would like to discard what's inside the polygon and keep the outside (e.g. make a hole in my raster).

Does anybody know how to do this?

marked as duplicate by user30184, PolyGeo Jun 15 '17 at 9:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    You could try making a big polygon, larger than the raster and cut the hole out. Every void that I've tried in GDAL/OGR has worked as expected so I would expect this to work too. Otherwise create two C polygons overlapping and cut twice. – Michael Stimson Jun 15 '17 at 3:16
  • You can't cut pixels from the middle of the raster but you can hide the area by painting the corresponding pixels with some other color. You will find answers from gis.stackexchange.com/questions/219355/… – user30184 Jun 15 '17 at 8:03
  • I edited the answer gis.stackexchange.com/questions/163371/… by adding the result of the standard operation with non-inverted vector mask. – user30184 Jun 15 '17 at 8:39
  • @user30184 thanks for your answer, but 'hiding pixels' with another layer on top is not what I'm looking for. My purpose is to assign 'null' values to a part or the raster (in a simple way, making a hole in it). Very simple in Mapinfo Discover. It would be great to have the option in GDAL and QGIS (with a simple command line option like -cropinside); hopefully some day it will exist. – jberrio Jun 16 '17 at 3:33
  • Gdal_rasterize does not create another layer. It is really changing the pixel values of the raster image permanently. You can set the new pixels to any value you want. In your case use you should use the nodata value of your image. Gdal_rasterize is your tool, please try it. – user30184 Jun 16 '17 at 4:33

@Michael Miles-Stimson thanks for your answer. I was checking if anybody knew an efficient way to do it (without the need to edit polygons, etc). It looks like Mapinfo Discover is still more efficient than GDAL for this task.

Clipping inside polygon in Encom Discover

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