module TopoPyScale.topo_param
Set of functions to work with DEMs S. Filhol, Oct 2021
TODO:
- an improvement could be to first copmute horizons, and then SVF to avoid computing horizon twice
function convert_epsg_pts
Simple function to convert a list fo poitn from one projection to another oen using PyProj
Args:
xs(array): 1D array with X-coordinate expressed in the source EPSGys(array): 1D array with Y-coordinate expressed in the source EPSGepsg_src(int): source projection EPSG codeepsg_tgt(int): target projection EPSG code
Returns:
array: Xs 1D arrays of the point coordinates expressed in the target projectionarray: Ys 1D arrays of the point coordinates expressed in the target projection
function get_extent_latlon
Function to extract DEM extent in Lat/Lon
Args:
dem_file(str): path to DEM file (GeoTiFF)epsg_src(int): EPSG projection code
Returns:
dict: extent in lat/lon, {latN, latS, lonW, lonE}
function extract_pts_param
Function to sample DEM parameters for a list point. This is used as an alternative the the TopoSub method, to perform downscaling at selected locations (x,y) WARNING: the projection and coordiante system of the EDM and point coordinates MUST be the same!
Args:
df_pts(dataframe): list of points coordinates with coordiantes in (x,y).ds_param(dataset): dem parametersmethod(str): sampling method. Supported 'nearest', 'linear' interpolation, 'idw' interpolation (inverse-distance weighted)
Returns:
dataframe: df_pts updated with new columns ['elevation', 'slope', 'aspect', 'aspect_cos', 'aspect_sin', 'svf']
function compute_dem_param
compute_dem_param(
dem_file,
fname='ds_param.nc',
project_directory=PosixPath('.'),
output_folder='outputs'
)
Function to compute and derive DEM parameters: slope, aspect, sky view factor
Args:
dem_file(str): path to raster file (geotif). Raster must be in local cartesian coordinate system (e.g. UTM)
Returns:
dataset: x, y, elev, slope, aspect, svf
function compute_horizon
compute_horizon(
dem_file,
azimuth_inc=30,
num_threads=None,
fname='da_horizon.nc',
output_directory=PosixPath('outputs')
)
Function to compute horizon angles for
Args:
dem_file(str): path and filename of the demazimuth_inc(int): angle increment to compute horizons at, in Degrees [0-359]num_threads(int): number of threads to parallize on
Returns:
dataarray: all horizon angles for x,y,azimuth coordinates
This file was automatically generated via lazydocs.