1

The following data sets are given:

  • 1 Polygon layer ("target areas")
  • Raster 1 (= digital elevation model)
  • Raster 2 (= temperature)

I have the following goals:

For each polygon in "target areas":

  • Extract the maximum elevation (including the respective x- and y-coordinates) from Raster 1
  • Add max_elev, max_elev_x and max_elev_y as new attributes to the attribute table of "target areas"
  • Extract the value at Coordinates max_elev_x/max_elev_y in Raster 2 (= Temperature at highest elevation in each polygon)
  • Add temp_max_elev as new attribute to the attribute table of "target areas"

I tried to solve this in QGIS with the field calculator and I am convinced it should work - but I failed so far.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Mar 20, 2022 at 17:51
0

1 Answer 1

2

There are in fact three steps you're asking for (last two points are one, in fact). I fear you can't do them at once using filed calculator alone. This is what you can do instead (automatize this workflow creating a model):

  1. To get the maximum value of the raster, this can be done using the following expression, where 1 is the band of the raster layer named raster1:

    raster_statistic( 'raster1',1,'max')

  2. To get the coordinates max_elev_x and max_elev_y of this maximum value is the most difficult part. See the solutions here: Identify the coordinates of the max values resulting from using the Zonal Statistics tool and Extract highest point in raster and convert to point vector

  3. Once you have the coordinates, you can get the raster value of the second raster using filed calculator with this expression, creating an attribute temp_max_elev: raster_value( 'raster2', 1, make_point(max_elev_x,max_elev_y))

answered Mar 20, 2022 at 22:12
2
  • Thanks for your help! I have already tried raster_statistic: with this function I get the maximum value over the entire raster, which is assigned to each individual polygon. So I have the same value in each polygon. However, what I want is the maximum value of the raster within each polygon area - I fail at this point... Commented Mar 22, 2022 at 17:42
  • Use Zonal statistics: docs.qgis.org/3.22/en/docs/user_manual/processing_algs/qgis/… Commented Mar 22, 2022 at 17:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.