reV.supply_curve.exclusions.LayerMask
- class LayerMask(layer, exclude_values=None, exclude_range=(None, None), include_values=None, include_range=(None, None), include_weights=None, force_include_values=None, force_include_range=None, use_as_weights=False, weight=1.0, exclude_nodata=False, nodata_value=None, extent=None, **kwargs)[source]
Bases:
object
Class to convert exclusion layer to inclusion layer mask
- Parameters:
layer (str) – Layer name.
exclude_values (int | float | list, optional) – Single value or list of values to exclude.
Important
The keyword arguments exclude_values, exclude_range, include_values, include_range, include_weights, force_include_values, and force_include_range are all mutually exclusive. Users should supply value(s) for exactly one of these arguments.
By default,
None
.exclude_range (list | tuple, optional) – Two-item list of [min threshold, max threshold] (ends are inclusive) for values to exclude. Mutually exclusive with other inputs (see info in the description of exclude_values). By default,
None
.include_values (int | float | list, optional) – Single value or list of values to include. Mutually exclusive with other inputs (see info in the description of exclude_values). By default,
None
.include_range (list | tuple, optional) – Two-item list of [min threshold, max threshold] (ends are inclusive) for values to include. Mutually exclusive with other inputs (see info in the description of exclude_values). By default,
None
.include_weights (dict, optional) – A dictionary of
{value: weight}
pairs, where thevalue
in the layer that should be included with the givenweight
. Mutually exclusive with other inputs (see info in the description of exclude_values). By default,None
.force_include_values (int | float | list, optional) – Force the inclusion of the given value(s). This input completely replaces anything provided as include_values and is mutually exclusive with other inputs (eee info in the description of exclude_values). By default,
None
.force_include_range (list | tuple, optional) – Force the inclusion of given values in the range [min threshold, max threshold] (ends are inclusive). This input completely replaces anything provided as include_range and is mutually exclusive with other inputs (see info in the description of exclude_values). By default,
None
.use_as_weights (bool, optional) – Option to use layer as final inclusion weights (i.e. 1 = fully included, 0.75 = 75% included, 0.5 = 50% included, etc.). If
True
, all inclusion/exclusions specifications for the layer are ignored and the raw values (scaled by the weight input) are used as inclusion weights. By default,False
.weight (float, optional) – Weight applied to exclusion layer after it is calculated. Can be used, for example, to turn a binary exclusion layer (i.e. data with 0 or 1 values and
exclude_values=1
input) into partial exclusions by setting the weight to a fraction (e.g. 0.5 for 50% exclusions). By default,1
.exclude_nodata (bool, optional) – Flag to exclude nodata values (nodata_value). If
nodata_value=None
the nodata_value is inferred byreV.supply_curve.exclusions.ExclusionMask
. By default,False
.nodata_value (int | float, optional) – Nodata value for the layer. If
None
, the value will be inferred when LayerMask is added toreV.supply_curve.exclusions.ExclusionMask
. By default,None
.extent (dict, optional) – Optional dictionary with values that can be used to initialize this class (i.e. layer, exclude_values, include_range, etc.). This dictionary should contain the specifications to create a boolean mask that defines the extent to which the original mask should be applied. For example, suppose you specify the input the following way:
input_dict = { "viewsheds": { "exclude_values": 1, "extent": { "layer": "federal_parks", "include_range": [1, 5] } } } for layer_name, kwargs in input_dict.items(): layer = LayerMask(layer_name, **kwargs) ...
This would mean that you are masking out all viewshed layer values equal to 1, but only where the “federal_parks” layer is equal to 1, 2, 3, 4, or 5. Outside of these regions (i.e. outside of federal park regions), the viewshed exclusion is NOT applied. If the extent mask created by these options is not boolean, an error is thrown (i.e. do not specify weight or use_as_weights). By default
None
, which applies the original layer mask to the full extent.**kwargs – Optional inputs to maintain legacy kwargs of
inclusion_*
instead ofinclude_*
.
Methods
Attributes
Values to exclude
Flag to force include mask
Values to include
Mapping of values to include and at what weights
Type of exclusion mask for this layer
Maximum value to include/exclude if include_range or exclude_range was input.
Minimum value to include/exclude if include_range or exclude_range was input.
Layer name to extract from exclusions .h5 file
- property name
Layer name to extract from exclusions .h5 file
- Returns:
_name (str)
- property min_value
Minimum value to include/exclude if include_range or exclude_range was input.
- Returns:
float
- property max_value
Maximum value to include/exclude if include_range or exclude_range was input.
- Returns:
float
- property exclude_values
Values to exclude
- Returns:
_exclude_values (list)
- property include_values
Values to include
- Returns:
_include_values (list)
- property include_weights
Mapping of values to include and at what weights
- Returns:
dict
- property force_include
Flag to force include mask
- Returns:
_force_include (bool)
- property mask_type
Type of exclusion mask for this layer
- Returns:
str