I have a raster file which I want to edit. My raster is the output of a classification (on Google Earth Engine), but some pixels in the edges of some features are wrongly classified (inside the red polygon) and I want to erase them. See example:


I know I can create a mask drawing polygons to cover the undesired pixels, but this is a huge image with a lot of imperfections, and it would take forever to fix it.

Is there some technique with QGIS that allows to 'erase' these pixels as if it was photoshop using some brush?

  • A raster is basically an image with a georeference. So you could possibly export to PNG, edit with any software you like (Krita, MS Paint even), load it back into whatever program you are using and georeference it again to your existing map :) Nov 19 '20 at 22:27
  • Not necessarily, it's more the other way around. An image is a raster file with image-like data types/formats. A geospatial raster can very well be using pixel values that normal image processing software cannot handle. Nov 19 '20 at 22:30
  • Oops, sorry :/ I've been playing around with loading PNGs into rasters lately, so I thought this. Thanks! I've learned a new thing Nov 19 '20 at 22:32
  • I was thinking on a combination of your ideas. Export my raster to PNG (at same native resolution), make edits, georeference image and use that image to mask my raster? Would it be possible? Nov 19 '20 at 22:44
  • Well, there's only one way to find out ;) In this specific case I think it is, Do you only have one band? making a mask sounds like a good option. Nov 20 '20 at 8:57

This is the better solution I found for this, using Photoshop and QGIS only.

  1. Open tiff file in photoshop and paint pixels. Depending on what you want to edit you may paint either black or white pixels (black pixels are masked out - no values, and white pixels have values). Save tiff file as a copy (avoid to overwrite the original file). enter image description here

  2. Open QGIS, use the georefencer tool in the Raster menu, import the edited tiff file and import 'GCP Points' file with the respective coordinates. The GCP file should have the same name as the edited tiff plus the extension .points (example: fileName.tif.points). The contents of this file should look like this:

enter image description here

Every row is a corner point in the image. From top to bottom the order of my points is: upper left, upper right, lower left, lower right. The first two columns are the extent coordinates obtained from the metadata of the original tiff (you can get it from the raster properties using QGIS). The next two columns are the extent of the edited tiff (the width and height in pixels). Note that the extent of my image in width (x-axis/longitude) is from 0 to 12879, and the height (y-axis/latitude) is from 0 to -11183. The signs are important. The other column values can be 1,0,0,0.

So you can georefence your image by loading this file in the georefencer tool.

  1. Finally I used this edited tiff file and used it as a mask to correct my original raster. The output looks like this (blue-corrected image and red-original image):

enter image description here

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.