2

I have a XYZ DEM of a fairly mountainous terrain and would like to identify flat areas using QGIS. How can calculate focal range in QGIS? Or would there be a way to do this in Spatialite?

Ideally, the output would be a shapefile of polygons of flat areas or a set of points representing centers of flat circles of certain radii.

1 Answer 1

4

This is doable with QGIS and SAGA (either standalone SAGA, or via the Processing panel in QGIS)

I assume by 'XZY DEM' you mean an ascii grid.

If the points are not regularly gridded (e.g. from UAS survey or LIDAR), you can also do this by importing into SAGA as a Point Cloud from an .xyz text file, then converting the point cloud into raster.

If it's an ascii gridded XYZ file, or a normal raster, you can import it using File > GDAL/OGR > Import Raster.

You can find flat areas using Terrain > Preprocessing > Flat Detection.

That will create two rasters;

  • one for flat areas only,
  • one for non-flat areas.

Depending on what you want, you can choose to set the pixel values for the flat raster to be set to either the elevation of each flat area ('elevation') or a unique ID ('enumeration'). Everything else is set to NODATA.

The screenshot below shows the unique ID for lochs in central Scotland. As far as I can tell, flat areas are numbered left-to-right, bottom-to-top, hence the colour gradient.

enter image description here

You can then convert these to polygons, either in SAGA or in QGIS, and use Simplify Geometries if necessary to remove the pixel artifacts along the edges.

EDIT:

To get an XYZ file into SAGA as a point cloud, use File > Shapes > Import > Point Cloud from Text File. I find the point clouds can be tricky to work with if RAM is tight, so I sometimes use a python script to randomly sample (say) 1% or 10% of points

Next, Shapes > Point Clouds > Conversion > Point Cloud to Grid You probably want the defaults (only Z, first value) but check to see if one of the other options is more apt for your needs (if more than one point maps to a pixel, you can choose the maximum, minimum, average etc).

You can also choose the pixel size. The files I work with have coords in UTM30N (meters), so the cell size is the number of meters per pixel.

Finally, you'll have a raster. Well, actually two rasters..

  • MyGrid [Z]
  • MyGrid [Points per cell]

The first one has your DEM, the second shows how many points fell into each pixel.

You may well have missing data - pixels where no samples were found (especially if you only work with a subset of the data).

To fix this, you can use either

  • Grid > Gaps > Close One cell gaps (fast, but only works with single pixel voids)
  • Grid > Gaps > Close Gaps (slow, but works with larger voids)
5
  • Thank you for the suggestions. The file I have is a xyz text file (ascii file). It is not regularly gridded so converting it to a nice raster is half my problem. Could you please expand a bit on how to "do this by importing into SAGA as a Point Cloud from an .xyz text file, then converting the point cloud into raster"? When I go to File --> PointCloud --> Load it's looking for SAGA Point Clouds (*.spc) if I force it to take my xyz.txt file the load fails. :( I am using SAGA 2.1.2 but must admit am not familiar with it very much.
    – PeterB
    Commented Sep 15, 2015 at 18:55
  • 1
    no problems, I'll edit the question once I've remembered how to do it.. I have done this in the past so I know it can be done.. SAGA is quite tricky to navigate even when you use it a lot ;-) Top tip: there's a 'Find and run Tool' which lets you search for tools. I've found some tools in there which I couldn't find in the menus at all...
    – Steven Kay
    Commented Sep 15, 2015 at 19:16
  • 1
    ok, edited the answer with point-cloud instructions!
    – Steven Kay
    Commented Sep 15, 2015 at 19:44
  • Great, That worked. but is there a way to define a "flat"? I was hoping to be able to specify that anything that is within say 15m (vertical) over 3 pixels is considered a flat - or some other way to define a range. SAGA seems to just crunch the terrain and spit out "no flats here". Any thoughts?
    – PeterB
    Commented Sep 16, 2015 at 4:48
  • 1
    hmmm. you might want to look at the SAGA filter Multiresolution Index of valley bottom flatness. I've not tried this myself, but it looks as if it might give you more control of the definition of "flat".
    – Steven Kay
    Commented Sep 16, 2015 at 9:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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