1

I have 10 overlaying rasters (both one- and multi-band) - same area, different date. I also have shapefile layer with 12 rectangle polygons. enter image description here

What I want is to extract proportion of raster inside each of rectangle and save it as JPEG image. Sure, it's easy to do it step by step. I select one polygon, clip the raster ten-times for each raster and then move to another polygon. The procedure is clear but please, is there any way how to make it automatically? I mean always select one polygon, extract it 10 times and then select another one - together make 120 pictures ideally in JPEG and save it to folder.

Maybe I could use Graphical Modeler but I'm not sure how to include the condition i+1 for selecting each polygon separately (something like for cycle). Probably it will be necessary to use Python Console but I'm not familiar with scripting in QGIS so far, so I'll need some hint.

  • Which tool(s) are you using to clip and export each raster? – BERA Jul 28 at 12:09
  • I would use Clip raster by mask, but as I need JPEG, it is easier for me to make just Printscreen - but it needs insane amount of time to finish it. – daky Jul 28 at 12:28
2

If I understand you correctly it is possible that all you need is the iterate over button that is in the clip raster by mask extent algorithm.
iterate over button Just set up the algorithm like you normally would and press the button and instead of using all of the features to cut the raster it will use each feature and return a separate image. It shouldn't take you long to run it 10 times.

Unfortunately I don't think it works with the batch processor and I don't think it is available in the graphical modeler.
A python script would probably be better if you where going to do this often but I don't know python.

| improve this answer | |
  • Thanks, than can save at least some time. Although it's not exactly what I wanted, it still really helps. – daky Jul 29 at 5:24
  • Do you just need jpeg compression or do you need to convert single band rasters to rgb jpegs? – Baswein Jul 29 at 10:19
  • I am not sure about the terminology, but just change the TIFF to JPEG - than it looks the same, has no georeferencing and is smaller. – daky Jul 30 at 8:10
  • If a jpeg from a print layout would work you could use the Atlas feature with your squares layer (with an inverted polygon style to mask out everything else)as your coverage layer. gisgeography.com/how-to-create-qgis-atlas-mapbooks – Baswein Jul 30 at 14:33

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.