0

I have a DEM in HGT format. I need to isolate all areas above a certain elevation and view them as polygons. Something like this (let's say the pink polygon is everything above 1000m):

DEM to polygon example

Seems like this would be a common GIS task, but all I found is the GRASS r.lake function. What I need is the opposite of a lake. :) QGIS/Python/GRASS solutions are preferred.

  • 2
    Reclassify into 2 classes, convert to polygons should work – jbalk Oct 4 '18 at 16:30
  • @jbalk: how would I do that? A full answer would be much appreciated. – kontextify Oct 5 '18 at 7:39
2

You can use:

enter image description here

enter image description here enter image description here

Convert line to polygon tool

enter image description here

To isolate area you can Clip DEM with polygon. I hope that is it.

  • 1
    Perfect! I used the GRASS r.contour.step command for the contour lines, then Vector > Geometry tools > Lines to polygons. Exactly what I needed. – kontextify Oct 5 '18 at 8:05
3

You can use r.recode to extract the areas above a certain altitude, and then r.to.vect to convert the resulting raster layer to a vector layer. The steps:

Import the data

You can import the data in a grass gis database using r.in.gdal or using the 'import raster data' menu (for more details see the grass wiki page Import of original SRTM tiles in HGT format.

Import raster data

Extract the area of interest

Next, you have various options to 'extract' the areas above a certain altitude, including the r.mapcalc, r.reclass and r.recode. In the example below, the r.recode function is used to reclassify all cells of the elevation map with a altitude > 120 to 1. The rest will be assigned a NULL (nodata) value.

Recode a raster layer

Note that the field marked with the blue asterisk will be automatically filled in (it is the path to a temporary file) when you enter the recode rule in the field below.

Convert from raster to vector

You can now convert the resulting raster layer to vector layer with the r.to.vect function.

Convert the raster layer 'highareas' to the vector polygon layer 'highareas'

Or all in once

You can use the steps above on the command line in one go:

r.recode input=elevation output=highareas rules=- << EOF
120:*:1
EOF
r.to.vect -s input=elevation@PERMANENT output=highareas type=area

And the result

This gives you a vector map of all areas with an altitude > 120.

Elevation map from the North Carolina sample dataset, overlaid with a vector layer (transparent blue area) with the areas with an altitude > 120

1

Just use QGIS:

  1. From the raster bar open the raster_calculator and perform your query, e.g.: "myDTM@1" > 1000 Result must be saved in a new raster, e.g.,"myDTM1000"
  2. From raster bar -> conversion open the polygonize tool and convert this raster into a polygon.

QGIS polygonize tool is based on a gdal function. You can even use directly gdal if you prefer.

0

Using GRASS raster calculator I would isolate the desired elevation as a binary raster and then convert is as a polygon.

With two commands in GRASS console:

r.mapcalc expression="elevation_1km = if(elevation >=10000 , 1, null())"

and then make it a polygon

r.to.vect -v input=elevation_1km output=elevation_poly type=area

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.