plans.datasets.spatial#
Handle spatial datasets (maps).
Overview#
# todo [major docstring improvement] – overview Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Example#
# todo [major docstring improvement] – examples Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla mollis tincidunt erat eget iaculis. Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl.
import numpy as np
print("Hello World!")
Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl. Mauris gravida ex quam, in porttitor lacus lobortis vitae. In a lacinia nisl.
Classes
|
AOI map dataset |
|
A |
|
Basins map dataset |
|
Distance to outlet raster map dataset. |
|
Equivalent Biodiversity Area raster map dataset. |
|
ET 24h raster map dataset. |
|
|
|
Elevation (DEM) raster map dataset. |
|
Flow Accumulation raster map dataset. |
|
HAND raster map dataset. |
|
HTWI (HAND-TWI) raster map dataset. |
|
Habitat Degradation raster map dataset. |
|
Habitat Quality raster map dataset. |
|
Primitive hydrology raster map dataset. |
|
LDD - Local Drain Direction map dataset |
|
Land Use and Land Cover map dataset |
|
Land Use and Land Cover Change map dataset |
|
A |
|
Lithology map dataset |
|
NDVI raster map dataset. |
|
|
|
Slope raster map dataset. |
|
Soils map dataset |
|
TWI raster map dataset. |
- class plans.datasets.spatial.Elevation(name='DEM')[source]#
Bases:
SciRasterElevation (DEM) raster map dataset.
- class plans.datasets.spatial.Slope(name='Slope')[source]#
Bases:
SciRasterSlope raster map dataset.
- class plans.datasets.spatial.HTWI(name='HTWI')[source]#
Bases:
SciRasterHTWI (HAND-TWI) raster map dataset.
- class plans.datasets.spatial.DTO(name='DTO')[source]#
Bases:
SciRasterDistance to outlet raster map dataset.
- class plans.datasets.spatial.FAC(name)[source]#
Bases:
SciRasterFlow Accumulation raster map dataset.
- class plans.datasets.spatial.NDVI(name, datetime)[source]#
Bases:
SciRasterNDVI raster map dataset.
- __init__(name, datetime)[source]#
Initialize dataset.
- Parameters:
name (str) – name of map
datetime (str) – date of map in
yyyy-mm-dd
- set_data(grid)[source]#
Set the data grid for the raster object. This function allows setting the data grid for the raster object. The incoming grid should be a NumPy array.
- Parameters:
grid (
numpy.ndarray) – The data grid to be set for the raster.
Notes
The function overwrites the existing data grid in the raster object with the incoming grid, ensuring that the data type matches the raster’s dtype.
Nodata values are masked after setting the grid.
- class plans.datasets.spatial.ET24h(name, date)[source]#
Bases:
SciRasterET 24h raster map dataset.
- __init__(name, date)[source]#
Initialize dataset.
- Parameters:
name (str) – name of map
date (str) – date of map in
yyyy-mm-dd
- set_data(grid)[source]#
Set the data grid for the raster object. This function allows setting the data grid for the raster object. The incoming grid should be a NumPy array.
- Parameters:
grid (
numpy.ndarray) – The data grid to be set for the raster.
Notes
The function overwrites the existing data grid in the raster object with the incoming grid, ensuring that the data type matches the raster’s dtype.
Nodata values are masked after setting the grid.
- class plans.datasets.spatial.Hydrology(name, varalias, datetime)[source]#
Bases:
SciRasterPrimitive hydrology raster map dataset.
- class plans.datasets.spatial.HabQuality(name, datetime)[source]#
Bases:
SciRasterHabitat Quality raster map dataset.
- class plans.datasets.spatial.HabDegradation(name, datetime)[source]#
Bases:
SciRasterHabitat Degradation raster map dataset.
- class plans.datasets.spatial.EBA(name, datetime, q_a=1.0)[source]#
Bases:
SciRasterEquivalent Biodiversity Area raster map dataset.
- __init__(name, datetime, q_a=1.0)[source]#
Initialize dataset.
- Parameters:
name (str) – name of map
datetime (str) – date of map in
yyyy-mm-ddq_a (float) – habitat quality reference
- set_data(grid)[source]#
Set the data grid for the raster object. This function allows setting the data grid for the raster object. The incoming grid should be a NumPy array.
- Parameters:
grid (
numpy.ndarray) – The data grid to be set for the raster.
Notes
The function overwrites the existing data grid in the raster object with the incoming grid, ensuring that the data type matches the raster’s dtype.
Nodata values are masked after setting the grid.
- class plans.datasets.spatial.Basins(name='BasinsMap')[source]#
Bases:
QualiRasterBasins map dataset
- static get_upstream_ids(basin_id, topology_df, visited=None)[source]#
Recursive utility function for listing all upstream basins
- Parameters:
basin_id (int) – basin id to start
topology_df (pandas.DataFrame) – dataframe with topology. expected to have Id and Downstream_Id columns
visited (list or None) – visited id (default=None)
- Returns:
upstream ids
- Return type:
list
- class plans.datasets.spatial.LULC(name, datetime)[source]#
Bases:
QualiRasterLand Use and Land Cover map dataset
- class plans.datasets.spatial.LULCChange(name, date_start, date_end, name_lulc)[source]#
Bases:
QualiRasterLand Use and Land Cover Change map dataset
- class plans.datasets.spatial.Lithology(name='LitoMap')[source]#
Bases:
QualiRasterLithology map dataset
- class plans.datasets.spatial.Soils(name='SoilsMap')[source]#
Bases:
QualiRasterSoils map dataset
- set_hydro_soils(map_lito, map_hand, map_slope, n_hand=2, n_slope=10)[source]#
Set hydrological soils based on lithology, Hand and Slope maps.
- Parameters:
map_lito (
datasets.Lithology) – Lithology raster mapmap_hand (
datasets.HAND) – HAND raster mapmap_slope (
datasets.Slope) – Slope raster mapn_hand (float) – HAND threshold for alluvial definition
n_slope (float) – Slope threshold for colluvial definition
- Returns:
None
- Return type:
None
- class plans.datasets.spatial.AOI(name='AOIMap')[source]#
Bases:
QualiHardAOI map dataset
- update()[source]#
Refresh all mutable attributes based on data (includins paths). Expected to be incremented downstream.
- Returns:
None
- Return type:
None
- get_table()[source]#
Retrieves a sample DataFrame representing an AOI classification table.
- Returns:
A DataFrame with sample AOI classification data.
- Return type:
pandas.DataFrame
- get_metadata()[source]#
Get a dictionary with object metadata. Expected to increment superior methods.
Note
Metadata does not necessarily inclue all object attributes.
- Returns:
dictionary with all metadata
- Return type:
dict
- view(show=True, folder='./output', filename=None, dpi=150, fig_format='jpg')[source]#
Plot a basic pannel of raster map.
- Parameters:
show (bool) – boolean to show plot instead of saving, defaults to False
folder (str) – path to output folder, defaults to
./outputfilename (str) – name of file, defaults to None
dpi (int) – image resolution, defaults to 96
fig_format (str) – image fig_format (ex: png or jpg). Default jpg
- class plans.datasets.spatial.LDD(name='LDDMap')[source]#
Bases:
QualiHardLDD - Local Drain Direction map dataset
LDD uses
wbtconvention derived from the WhiteboxTool.wbtconvention#64
128
1
32
0
2
16
8
4
- class plans.datasets.spatial.NDVISeries(name)[source]#
Bases:
RasterSeries- __init__(name)[source]#
Deploy RasterSeries
- Parameters:
name (str) –
RasterSeries.name`name attributevarname (str) –
Raster.varname`variable name attribute, defaults to Nonevaralias (str) –
Raster.varalias`variable alias attribute, defaults to Noneunits (str) –
Raster.units`units attribute, defaults to None
- load_data(name, datetime, file_data, prj_file)[source]#
Load a
NDVI`object from a raster file.- Parameters:
name (str) – name attribute
datetime (str) –
Raster.date`date attribute, defaults to Nonefile_data (str) – path to
.ascraster fileprj_file (str) – path to
.prjprojection file
- Returns:
None
- Return type:
None
- class plans.datasets.spatial.ETSeries(name)[source]#
Bases:
RasterSeries- __init__(name)[source]#
Deploy RasterSeries
- Parameters:
name (str) –
RasterSeries.name`name attributevarname (str) –
Raster.varname`variable name attribute, defaults to Nonevaralias (str) –
Raster.varalias`variable alias attribute, defaults to Noneunits (str) –
Raster.units`units attribute, defaults to None
- load_data(name, datetime, file_data, prj_file)[source]#
Load a
ET24h`object from a raster file.- Parameters:
name (str) – name attribute
datetime (str) – datetime attribute, defaults to None
file_data (str) – path to raster file
prj_file (str) – path to projection file
- Returns:
None
- Return type:
None
- class plans.datasets.spatial.AOICollection(name)[source]#
Bases:
QualiRasterCollectionA
QualiRasterCollection`for holding AOI maps
- class plans.datasets.spatial.LULCSeries(name)[source]#
Bases:
QualiRasterSeriesA
QualiRasterSeriesfor holding Land Use and Land Cover maps- __init__(name)[source]#
Deploy Qualitative Raster Series
- Parameters:
name (str) –
RasterSeries.name`name attributevarname (str) –
Raster.varnamevariable name attribute, defaults to Nonevaralias (str) –
Raster.varaliasvariable alias attribute, defaults to None
- load_data(name, datetime, file_data, file_prj=None, file_table=None)[source]#
Load a
LULC`object from raster file.- Parameters:
name (str) – name attribute
datetime (str) – date attribute
file_data (str) – path to raster file
file_prj (str) – path to projection file
file_table (str) – path to table file
- Returns:
None
- Return type:
None
- get_lulcc(date_start, date_end, by_lulc_id)[source]#
Get the
LULCChange`of a given time interval and LULC class Id- Parameters:
date_start (str) – start date of time interval
date_end (str) – end date of time interval
by_lulc_id (int) – LULC class Id
- Returns:
map of LULC Change
- Return type:
- get_lulcc_series(by_lulc_id)[source]#
Get the
QualiRasterSeriesof LULC Change for the entire LULC series for a given LULC Id- Parameters:
by_lulc_id (int) – LULC class Id
- Returns:
Series of LULC Change
- Return type:
QualiRasterSeries
- get_conversion_matrix(date_start, date_end, talk=False)[source]#
Compute the conversion matrix, expansion matrix and retraction matrix for a given interval
- Parameters:
date_start (str) – start date of time interval
date_end (str) – end date of time interval
talk (bool) – option for printing messages
- Returns:
dict of outputs
- Return type:
dict