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:
SciRaster
Elevation (DEM) raster map dataset.
- class plans.datasets.spatial.Slope(name='Slope')[source]#
Bases:
SciRaster
Slope raster map dataset.
- class plans.datasets.spatial.HTWI(name='HTWI')[source]#
Bases:
SciRaster
HTWI (HAND-TWI) raster map dataset.
- class plans.datasets.spatial.DTO(name='DTO')[source]#
Bases:
SciRaster
Distance to outlet raster map dataset.
- class plans.datasets.spatial.FAC(name)[source]#
Bases:
SciRaster
Flow Accumulation raster map dataset.
- class plans.datasets.spatial.NDVI(name, datetime)[source]#
Bases:
SciRaster
NDVI 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:
SciRaster
ET 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:
SciRaster
Primitive hydrology raster map dataset.
- class plans.datasets.spatial.HabQuality(name, datetime)[source]#
Bases:
SciRaster
Habitat Quality raster map dataset.
- class plans.datasets.spatial.HabDegradation(name, datetime)[source]#
Bases:
SciRaster
Habitat Degradation raster map dataset.
- class plans.datasets.spatial.EBA(name, datetime, q_a=1.0)[source]#
Bases:
SciRaster
Equivalent 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-dd
q_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:
QualiRaster
Basins map dataset
- __init__(name='BasinsMap')[source]#
Initialize dataset.
- Parameters:
name (str) – name of map
dtype (str) – data type of raster cells, defaults to
- 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:
QualiRaster
Land Use and Land Cover map dataset
- class plans.datasets.spatial.LULCChange(name, date_start, date_end, name_lulc)[source]#
Bases:
QualiRaster
Land Use and Land Cover Change map dataset
- class plans.datasets.spatial.Lithology(name='LitoMap')[source]#
Bases:
QualiRaster
Lithology map dataset
- class plans.datasets.spatial.Soils(name='SoilsMap')[source]#
Bases:
QualiRaster
Soils map dataset
- __init__(name='SoilsMap')[source]#
Initialize dataset.
- Parameters:
name (str) – name of map
dtype (str) – data type of raster cells, defaults to
- 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:
QualiHard
AOI map dataset
- __init__(name='AOIMap')[source]#
Initialize dataset.
- Parameters:
name (str) – name of map
dtype (str) – data type of raster cells, defaults to
- 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
./output
filename (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:
QualiHard
LDD - Local Drain Direction map dataset
LDD uses
wbt
convention derived from the WhiteboxTool.wbt
convention#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
.asc
raster fileprj_file (str) – path to
.prj
projection 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:
QualiRasterCollection
A
QualiRasterCollection`
for holding AOI maps
- class plans.datasets.spatial.LULCSeries(name)[source]#
Bases:
QualiRasterSeries
A
QualiRasterSeries
for holding Land Use and Land Cover maps- __init__(name)[source]#
Deploy Qualitative Raster Series
- Parameters:
name (str) –
RasterSeries.name`
name attributevarname (str) –
Raster.varname
variable name attribute, defaults to Nonevaralias (str) –
Raster.varalias
variable 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
QualiRasterSeries
of 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