cwatm.dem#

cwatm.dem(data, *, mask=None, bounds=None, resolution=None, x0=None, y0=None, base_template=None, outpath=None, **rio_kwargs)[source]#

Format standardized DEM data for CWatM:

  • reproject and clip them into passed resolution, mask, dst_crs, x0, y0

  • generate matching maps of flow directions

  • generate matching maps of standard deviations of elevation

Parameters#

datapath (str or pathlib.Path), or variable (numpy.ndarray, xarray.Dataset or xarray.DataArray)

MNT Dataset retrieved from IGN “ALTI” database https://geoservices.ign.fr/bdalti

mask(list of) str, pathlib.Path, shapely.geometry, xarray.DataArray or geopandas.GeoDataFrame, optional

Filepath of mask used to clip the data.

boundsiterable or None, optional, default None

Boundaries of the target domain as a tuple (x_min, y_min, x_max, y_max).

resolution(list of) int, optional

List of resolutions to use for data formating.

x0: number, optional, default None

Origin of the X-axis, used to align the reprojection grid.

y0: number, optional, default None

Origin of the Y-axis, used to align the reprojection grid.

base_templatestr, pathlib.Path, xarray.DataArray or geopandas.GeoDataFrame, optional

Filepath, used as a template for spatial profile. Supported file formats are .tif, .nc and vector formats supported by geopandas (.shp, .json, …).

outpathstr, optional

Outpath stem when data is passed as a GEOP4TH variable instead of a filepath.

**rio_kwargskeyword args, optional

Argument passed to the xarray.Dataset.rio.reproject() function call.

Note: These arguments are prioritary over base_template attributes.

May contain:

  • dst_crs : str

  • resolution : float or tuple

  • shape : tuple (int, int)

  • transform : Affine

  • nodata : float or None

  • resampling :

    • see help(rasterio.enums.Resampling)

    • most common are: 5 (average), 13 (sum), 0 (nearest), 9 (min), 8 (max), 1 (bilinear), 2 (cubic)…

    • the functionality 'std' (standard deviation) is also available

  • see help(xarray.Dataset.rio.reproject)

Returns#

None. Generate the formated files, with filepaths derived from data or from outpath.

Examples#

>>> cwatm.dem(
    r"E:\Inputs\DEM\IGN\BDALTIV2_folder\BDALTIV2_stz.tif", 
    resolution = [500, 1000], 
    x0 = 0, 
    y0 = 0, 
    dst_crs = 27572, 
    mask = r"E:\Inputs\masks\MyMask.shp"
    )
Exporting...
   _ Success: The data has been exported to the file 'E:\Inputs\DEM\IGN\BDALTIV2\BDALTIV2_stz_CWATM_1000m_mask1.tif'
Exporting...
   _ Success: The data has been exported to the file 'E:\Inputs\DEM\IGN\BDALTIV2\ElevationStD_BDALTIV2_stz_CWATM_1000m_mask1.tif'
Exporting...
   _ Success: The data has been exported to the file 'E:\Inputs\DEM\IGN\BDALTIV2\BDALTIV2_stz_CWATM_500m_mask1.tif'
Exporting...
   _ Success: The data has been exported to the file 'E:\Inputs\DEM\IGN\BDALTIV2\ElevationStD_BDALTIV2_stz_CWATM_500m_mask1.tif'