1

I'm using QGIS 3 to see if point features I have from a delimited text layer can be selected based on if they cross / are overlayed on a specific color from a separate raster layer. I'm using point source emission data to analyze emission levels in cities for a university project. The raster layer (geotiff) was obtained from this source: https://www.arcgis.com/home/item.html?id=fc92d38533d440078f17678ebc20e8e2

I'm trying to see what point emission values interact with the "Built Area" portion of the raster which is a specific color. If there is a way to select and export only the "Built Area" portion of the raster that would also work, but I wasn't sure if this could be done either.

1 Answer 1

2

I am using QGIS 3.26.3.

If your raster is categorised and the colour corresponds to a particular value, you can use Select by expression on your points like so:

// select points that fall inside pixels (in band 1) with value 3
raster_value('my raster layer', 1, $geometry) = 3

However, if you are working with an RGB image, you could get the RGB values of your raster and filter/select your points based on ranges of colour.

Calculate a field called R:

// Red band of a raster layer called 'qgis'
raster_value('qgis', 1, $geometry)

Repeat for G and B using band 2 and band 3 in place of 1.

Then select your points based on the RGB values. For example here I choose the most red and least blue points using Select by expression:

"R" > 150 and "B" < 100

enter image description here

enter image description here

You could also use an array to store the RGB values, or indeed use the raster_value function directly in select by expression. I used 3 separate fields here for clarity.

The raster_value function was introduced in a fairly recent version of QGIS but I don't remember which off the top of my head.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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