RSGISLib Elevation Module

The elevation module contains functions for performing analysis on elevation data.

rsgislib.elevation.fftDEMFusion(highResDEMImg, lowResDEMImg, fusedDEMImg, cSize=20)

This function merges DEMs (any single band file) using a fourier transformation where the low frequency component is taken from the lower resolution DEM and the high frequency component is taken from the higher resolution DEM.

This is an implemenetation ideas from:

Karkee, M., Steward, B. L., & Aziz, S. A. (2008). Improving quality of public domain digital elevation models through data fusion. Biosystems Engineering, 101(3), 293–305.

Parameters
  • highResDEMImg – is an input image file for the high resolution DEM file.

  • lowResDEMImg – is an input image file for the low resolution DEM file.

  • fusedDEMImg – is an output image file for the resulting fused DEM.

  • cSize – is the threshold (int) defining the high and low frequencies.

Slope and Aspect

rsgislib.elevation.slope(inputImage, outputImage, outAngleUnit, gdalformat)

Calculates a slope layer given an input elevation model.

Where:

Parameters
  • inputImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • outAngleUnit – is a string specifying the output unit (‘degrees’ or ‘radians’).

  • gdalformat – is a string with the output image format for the GDAL driver.

rsgislib.elevation.aspect(inputImage, outputImage, gdalformat)

Calculates a aspect layer given an input elevation model

Where:

Parameters
  • inputImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • gdalformat – is a string with the output image format for the GDAL driver.

rsgislib.elevation.catagoriseAspect(inputImage, outputImage, gdalformat)

Creates an aspect layer which is categorised into 8 catergories from 0-45, 45-90, 90-135, 135-180, 180-225, 225-270, 270-315 and 315-360.

Where:

Parameters
  • inputImage – is a string containing the name and path of the input aspect (in degrees) file.

  • outputImage – is a string containing the name and path of the output file.

  • gdalformat – is a string with the output image format for the GDAL driver.

Flitering

rsgislib.elevation.dtmAspectMedianFilter(inputDTMImage, inputAspectImage, outputImage, aspectRange, winHSize, gdalformat)

Filter the DTM for noise using a median filter with an aspect restriction (i.e., only pixels within the aspect range of the centre pixel will be used within the median filter).

Where:

Parameters
  • inputDTMImage – is a string containing the name and path of the input DTM file.

  • inputAspectImage – is a string containing the name and path of the input Aspect file (in degrees).

  • outputImage – is a string containing the name and path of the output file.

  • aspectRange – is a float with the range of from the centre pixel in degrees.

  • winHSize – is an integer for half the window size.

  • gdalformat – is a string with the output image format for the GDAL driver.

rsgislib.elevation.fillDEMSoilleGratin1994(inputDEMImage, validMaskImage, outputImage, gdalformat)

Filter the local minima in a DEM using the Soille and Gratin 1994 algorithm.

Soille, P., and Gratin, C. (1994). An efficient algorithm for drainage network extraction on DEMs. J. Visual Communication and Image Representation. 5(2). 181-189.

Where:

Parameters
  • inputDEMImage – is a string containing the name and path of the input DEM file.

  • validMaskImage – is a string containing the name and path to a binary image specifying the valid data region (1 == valid)

  • outputImage – is a string containing the name and path of the output file.

  • gdalformat – is a string with the output image format for the GDAL driver.

Example:

import rsgislib.elevation
inputDEMImage = 'DEM.kea'
validMaskImage = 'ValidRegionMask.kea'
outFilledImage = 'DEM_filled.kea'
rsgislib.elevation.fillDEMSoilleGratin1994(inputDEMImage, validMaskImage, outFilledImage, 'KEA')
rsgislib.elevation.planeFitDetreatDEM(inputDEMImage, outputImage, gdalformat, winSize)

An algorithm to detread a DEM using local plane fitting. The winSize will define the scale at which the DEM will be detreaded.

Where:

Parameters
  • inputDEMImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • gdalformat – is a string with the output image format for the GDAL driver.

  • winSize – is an integer with the window size within which the plane is fitted.

Example:

import rsgislib.elevation
inputDEMImage = 'DEM.kea'
outDEMImage = 'DEM_Detread.kea'
rsgislib.elevation.planeFitDetreatDEM(inputDEMImage, outDEMImage, 'KEA', 11)

Masking

rsgislib.elevation.shadowmask(inputImage, outputImage, solarAzimuth, solarZenith, maxHeight, gdalformat)

Calculates a shadow mask given an input elevation model

Where:

Parameters
  • inputImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • solarAzimuth – is a float with the solar azimuth in degrees.

  • solarZenith – is a float with the solar zenith in degrees.

  • maxHeight – is a float with the maximum height for the ray tracing (should be above the maximum elevation within the scene).:param gdalformat: is a string with the output image format for the GDAL driver.

Incidence / Existance Angle

rsgislib.elevation.localIncidenceAngle(inputImage, outputImage, solarAzimuth, solarZenith, gdalformat)

Calculates a local solar incidence angle layer given an input elevation model

Where:

Parameters
  • inputImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • solarAzimuth – is a float with the solar azimuth in degrees.

  • solarZenith – is a float with the solar zenith in degrees.

  • gdalformat – is a string with the output image format for the GDAL driver.

rsgislib.elevation.localExistanceAngle(inputImage, outputImage, azimuth, zenith, gdalformat)

Calculates a local solar existance angle layer given an input elevation model

Where:

Parameters
  • inputImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • azimuth – is a float with the solar azimuth in degrees.

  • zenith – is a float with the solar zenith in degrees.

  • gdalformat – is a string with the output image format for the GDAL driver.

Visualisation

rsgislib.elevation.hillshade(inputImage, outputImage, solarAzimuth, solarZenith, gdalformat)

Calculates a hillshade layer given an input elevation model

Where:

Parameters
  • inputImage – is a string containing the name and path of the input DEM file.

  • outputImage – is a string containing the name and path of the output file.

  • solarAzimuth – is a float with the solar azimuth in degrees (Good value is 315).

  • solarZenith – is a float with the solar zenith in degrees (Good value is 45).

  • gdalformat – is a string with the output image format for the GDAL driver.

Fusion

rsgislib.elevation.fftDEMFusion(highResDEMImg, lowResDEMImg, fusedDEMImg, cSize=20)

This function merges DEMs (any single band file) using a fourier transformation where the low frequency component is taken from the lower resolution DEM and the high frequency component is taken from the higher resolution DEM.

This is an implemenetation ideas from:

Karkee, M., Steward, B. L., & Aziz, S. A. (2008). Improving quality of public domain digital elevation models through data fusion. Biosystems Engineering, 101(3), 293–305.

Parameters
  • highResDEMImg – is an input image file for the high resolution DEM file.

  • lowResDEMImg – is an input image file for the low resolution DEM file.

  • fusedDEMImg – is an output image file for the resulting fused DEM.

  • cSize – is the threshold (int) defining the high and low frequencies.