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.
1 Answer 1
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):
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 namedraster1
:raster_statistic( 'raster1',1,'max')
To get the coordinates
max_elev_x
andmax_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 vectorOnce 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))
-
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...Anatol– Anatol2022年03月22日 17:42:58 +00:00Commented Mar 22, 2022 at 17:42
-
Use Zonal statistics: docs.qgis.org/3.22/en/docs/user_manual/processing_algs/qgis/…Babel– Babel2022年03月22日 17:47:23 +00:00Commented Mar 22, 2022 at 17:47
Explore related questions
See similar questions with these tags.