# Clipping polygon layer according to DEM elevation using QGIS?

I have a polygon layer on top of a DEM. Is there a way to clip the polygon layer according to elevation, ie the clipped result being only those areas of the polygon layer between x and y altitude?

The result needs to be a vector layer.

• I'd suggest converting the target area (elevation range) in the DEM you're interested in to a vector, and using that output to clip the polygon layer. An extra step, but in QGIS alone, that might be the only way to go...? Jun 5, 2014 at 16:32
• Have you tried Raster Calculator? docs.qgis.org/2.2/en/docs/user_manual/working_with_raster/… Using a mask If you want to mask out parts of a raster – say, for instance, because you are only interested in elevations above 0 meters – you can use the following expression to create a mask and apply the result to a raster in one step. ("elevation@1" >= 0) * "elevation@1" In other words, for every cell greater than or equal to 0, set its value to 1. Otherwise set it to 0. This creates the mask on the fly. Jun 5, 2014 at 19:01

I'd try converting the DEM to contours via Raster > Extraction > Contour to help with this clip.

I don't know about the way to do it in one step but here is a 3 step way:

1. Use Raster / Raster calculator... to get raster 1 / Null with 1 for your altitude interval and null for the rest like:

• General: "dem@1" > min_altitude AND "dem@1" < max_altitude
• Example: "dem@1" > 250 AND "dem@1" < 300
2. Use Raster / Conversion / Polygonize (Raster to Polygon) to make polygon(s) from the raster which is area of your altitude interval

3. Use Vector / Geoprocessing tools / Clip to clip your polygon by polygon from 2. step - area of your altitude interval. That will give you polygon clipped by DEM elevation interval

In theory there is also way to use Contour plugin which has option to generate filled contours (your area for clipping). Advantage is that your clipping area would not be as "pixelated" as area with the approach above. But unfortunately this plugin works only on points. That would involve to convert your DEM into points first and considering bigger raster size Contour plugin might not be able to crunch it in reasonable time or not at all.

• The Raster Calculator / Polygonize / Clip method works well, thanks. In my case the polygonization always gives a vector with some invalid geometries that need fixing before Clip will run successfully. The "Fix Geometries" tool from the toolbox does this nicely. Jul 2, 2020 at 11:42