2

I am working with QGIS and have a raster file with two bands. Band one contains two values, event types, and Band 2 contains a date where the amount of a Band one event occurring sums up.

An example would be that one pixel contains Band 1 value: 2 and Band 2 value: 20001.

I want to extract that information in a CSV file so that I can see what happened when. However, when using Zonal histogram in QGIS there's only the option of extracting information from one band.

Are there other tools in QGIS or any other way of getting the result I am looking for?

0

2 Answers 2

0

Just execute zonal histogram twice, one for each band, using the output from zonal histogram 1 as input to 2.

0
  1. Create a grid with the same CRS, extent and pixel size as the raster layer.

  2. Use Field calculator to generate two new fields, one for each band. The expression to use is raster_value ('raster_layer', 1, centroid ($geometry)

    Replace raster_layer with the name of you raster layer and 1 with the number of the band you want to get.

  3. Save the grid as CSV.


Remark: you could run steps 2 and 3 for both bands at once in one single run using Field calculator in batch mode. But for this simple workflow, that would be an overkill (as you have to know how to fill in correctly the variable values in batch mode).

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.