DEM tools

A collection of functions to handle digital elevation models in GAMMA

dem_autocreate

dem_import

convert an existing DEM in GDAL-readable format to GAMMA format including optional geoid-ellipsoid conversion.

dempar

create GAMMA parameter text files for DEM files

fill

interpolate missing values in the SRTM DEM (value -32768)

mosaic

mosaicing of multiple DEMs

swap

byte swapping from small to big endian (as required by GAMMA)

pyroSAR.gamma.dem.dem_autocreate(geometry, demType, outfile, buffer=None, t_srs=4326, tr=None, logpath=None, username=None, password=None, geoid_mode='gamma', resampling_method='bilinear')[source]
automatically create a DEM in GAMMA format for a defined spatial geometry.
The following steps will be performed:
  • collect all tiles overlapping with the geometry using pyroSAR.auxdata.dem_autoload()

    • if they don’t yet exist locally they will automatically be downloaded

    • the tiles will be downloaded into the SNAP auxdata directory structure, e.g. $HOME/.snap/auxdata/dem/SRTM 3Sec

  • create a mosaic GeoTIFF of the same spatial extent as the input geometry plus a defined buffer using pyroSAR.auxdata.dem_create()

  • if necessary, subtract the geoid-ellipsoid difference (see pyroSAR.auxdata.dem_autoload() for height references of different supported DEMs)

  • convert the result to GAMMA format

    • If t_srs is 4326 and the DEM’s height reference is either WGS84 ellipsoid or EGM96 geoid, the command srtm2dem can be used. This is kept for backwards compatibility.

    • For all other cases the newer command dem_import can be used if it exists and if the command create_dem_par accepts a parameter EPSG.

Parameters:
  • geometry (Vector) – a vector geometry delimiting the output DEM size

  • demType (str) – the type of DEM to be used; see dem_autoload() for options

  • outfile (str) – the name of the final DEM file

  • buffer (int | float | None) – a buffer in degrees to create around the geometry

  • t_srs (int | str | SpatialReference) – A target geographic reference system in WKT, EPSG, PROJ4 or OPENGIS format. See function spatialist.auxil.crsConvert() for details. Default: 4326.

  • tr (tuple[int | float, int | float] | None) – the target resolution as (xres, yres) in units of t_srs; if t_srs is kept at its default value of 4326, tr does not need to be defined and the original resolution is preserved; in all other cases the default of None is rejected

  • logpath (str | None) – a directory to write GAMMA logfiles to

  • username (str | None) – (optional) the user name for services requiring registration; see dem_autoload()

  • password (str | None) – (optional) the password for the registration account

  • geoid_mode (Literal['gamma', 'gdal']) – the software to be used for converting geoid to ellipsoid heights (if necessary)

  • resampling_method (str) – the gdalwarp resampling method; See here for options.

Return type:

None

pyroSAR.gamma.dem.dem_import(src, dst, geoid=None, logpath=None, outdir=None, shellscript=None)[source]

convert an existing DEM in GDAL-readable format to GAMMA format including optional geoid-ellipsoid conversion.

Parameters:
  • src (str) – the input DEM

  • dst (str) – the output DEM

  • geoid (Literal['EGM96', 'EGM2008'] | None) – the geoid height reference of src; supported options. Default None: assume WGS84 ellipsoid heights and do not convert heights.

  • logpath (str | None) – a directory to write logfiles to

  • outdir (str | None) – the directory to execute the command in

  • shellscript (str | None) – a file to write the GAMMA commands to in shell format

Return type:

None

pyroSAR.gamma.dem.dempar(dem, logpath=None)[source]

create GAMMA parameter text files for DEM files

currently only EQA and UTM projections with WGS84 ellipsoid are supported

Parameters:
  • dem (str) – the name of the DEM

  • logpath (str | None) – a directory to write logfiles to

Return type:

None

pyroSAR.gamma.dem.fill(dem, dem_out, logpath=None, replace=False)[source]

interpolate missing values in the SRTM DEM (value -32768)

Parameters:
  • dem (str) – the input DEM to be filled

  • dem_out (str) – the name of the filled DEM

  • logpath (str | None) – a directory to write logfiles to

  • replace (bool) – delete dem once finished?

Return type:

None

pyroSAR.gamma.dem.mosaic(demlist, outname, byteorder=1, gammapar=True)[source]

mosaicing of multiple DEMs

Parameters:
  • demlist (list[str]) – a list of DEM names to be mosaiced

  • outname (str) – the name of the final mosaic file

  • byteorder (Literal[0, 1]) –

    the byte order of the mosaic

    • 0: small endian

    • 1: big endian

  • gammapar (bool) – create a GAMMA parameter file for the mosaic?

Return type:

None

pyroSAR.gamma.dem.swap(data, outname)[source]

byte swapping from small to big endian (as required by GAMMA)

Parameters:
  • data (str) – the DEM file to be swapped

  • outname (str) – the name of the file to write

Return type:

None