# Extract the mean elevation from a raster by a mask with several spatial objects

I am working with a glacier and I want to get the Hypsometric curve of the elevation difference between two time periods. I divided the mask of the glacier by the contour lines (each 50 m) and now I want to extract the information of the raster with the elevation difference for each area that is between the contour lines.

My idea was by taking each one of the +100 polygons that are in the mask and exctracting the raster by each on of them, and then getting the statistic, but that seems like a very long step, and I have 24 more glaciers to analyse.

Does any one know a better way to do this using QGIS? Or also with R, but I am not so good in that last one.

I put an image with reference and with a part of the raster that was extracted. ## 1 Answer

1. Create a difference layer with the Raster Calculator, to get the difference in glacier heights over time, ie. Raster2 - Raster1. This will create a new raster layer

2. Use Zonal Statistics on the new layer to compute the mean difference within each polygon.

Let us know if you get stuck.

• Hello, yes, the first step is the DEM I am using, and I want to know how much was the elevation difference in each elevation. I used the Zonal Statistic and it worked! I must select every object before and make the analyses then. Now is more easy, even though I still have to pass by hand the superior and inferior elevation given by the contour line of each area to make the hypsometric curve, but this is a great advance. Thank you! – Felipe Gomez Apr 23 at 4:51
• If your contour data are in different layers, then merge them to a single layer first. That will save a lot of time. Calculate the difference between rasters, then run zonal statistics using a single merged polygon layer and a single difference raster. – wingnut Apr 23 at 5:12
• Yes, you are right, I just tried that but the contour lines dont have the same geometry than the polygons with the areas. But I tried other thing that worked. I made the same that I did with the raster of the elevation difference (-5 m -10 m -15 m...), but now with the raster with the real elevations (2500 m 2550 m 2600 m). So the zonal statistic gave me the minimum and maximum of each area, from which I can deduce between which elevation it is the area and the media of elevation difference that was calculated before. Thank you so much for the help, and greetings from Chile! :) – Felipe Gomez Apr 23 at 5:42