2

I know this sounds quite difficult, but maybe it isn't for you or at least it shouldn't if I explain it correctly.

(I'm using QGIS 2.14) I'd like to know to calculate total area overlapping a specific raster DEM color (user-specified altitude interval) whose boundaries are confined by another vector.

So basically there's a raster DEM as background map, I assigned a specific color to an altitude interval. I applied a vector I created to show where boundaries of a certain area area. Now within this area, I applied another raster which partly overlaps the altitude interval I applied in the background DEM.

I'd like to know what is the area, within the vector boundaries, that overlaps my altitude interval in the DEM map.

enter image description here

EDIT: I tried running raster calculator on intersections then zonal statistics checking "count" and "sum" but I get a huge table of 8000+ rows and two columns, however each cell usually have a value around 0.4 or 1.x, so I don't know how to interpret this or if I should somehow sum all those cells together to get the number of pixels falling in my area of interest (overlapping altitude range, shaded and within vector bounday).

1 Answer 1

2

To put things clear, I assume that you want to compute the area which responds to the following conditions:

  • located inside your DEM altitude interval
  • located inside your vector boundaries
  • located where your second raster (let's call it raster2) has values other than "nodata" (this is the unclear part of your post, feel free to correct me if I misunderstood).

There are several ways to perform this; here's what I think is the most simple approach (let's call z1-z2 your altitude interval):

  1. first, your data need to have an equal-area projection if you want to compute meaningful areas. So, if it's not already the case, choose a projection that fits the region you're mapping, then reproject your raster and vector layers to it (using "Save As" for vector layers and "Raster > Projections > Warp" for rasters).

  2. use the raster calculator to create a mask representing the parts of raster2 located inside your DEM interval. The formula will be something like ("raster2@1" != -9999) * ("dem@1" >= z1) * ("dem@1" <= z2). You should get a raster with 1s in your altitude interval and 0s or "nodata" everywhere else. (Note: the"raster2@1" != -9999 part should be fine, but depending on raster2's values you might have to adjust it).

  3. install the Zonal Statistics plugin. This plugin computes statistics on a raster, within polygons. Once installed, it will be located in the "raster" menu. Choose the previously created mask as "raster layer", and the vector layer which contains your boundaries as "Polygon layer". If this vector layer contains a lot of polygons, you might prefer to export the polygon representing your boundaries as a separate vector layer (it will be less time consuming). If everything goes well, you'll get additional fields in your vector layer; among them will be a "count" column which represents the number of mask pixels inside every polygon from the vector layer. You just have to multiply the number in this column by the area of a pixel (cellsize) - which depends on the projection - to get your final area.

11
  • I see, thank you. One of my problems is that I don't need the entire area of "raster2" overlapping my DEM, but only that overlapping DEM over values higher than say 800 m of altitude (I applied a color shading to areas higher than that but also got other colors at lower altitudes).
    – Allison R
    May 1, 2016 at 17:20
  • This isn't really a problem. Step 2 will give you the intersection of your DEM interval and raster2. Step 3 computes the intersection of the mask from step 2 and your vector layer. By the way, color doesn't really matter here.
    – ArMoraer
    May 1, 2016 at 17:26
  • Added example picture, I apologize for my poor explanation.
    – Allison R
    May 1, 2016 at 17:33
  • 1
    Your explanation was good, this was what I understood ;) Have you tried the method I gave? If so, is there something wrong with it?
    – ArMoraer
    May 1, 2016 at 17:39
  • 1
    I carefully checked every layer and apparently vectors saved in KML format lose the assigned CRS equal area value to WGS84, so I saved them again in SHP format and they seem to keep the assigned Albers conical. I've run again this small test, raster calculator and zonal statistics, yet I still get 8000+ rows and 2 columns, with each cell having a value around 0.4, very few having a value of 2 and some other few a value around 1. Trying to select the vector and opening statistics again plus Ctrl+T still gives 4 cells of 0.4 each. Should I sum each 8000+ column to get my evading pixel count?
    – Allison R
    May 2, 2016 at 15:36

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.