te_schemas.land_cover
- class te_schemas.land_cover.LCClass
LCClass(code: ‘int’, name_short: ‘Union[str, None]’ = None, name_long: ‘Union[str, None]’ = None, description: ‘Optional[str]’ = None, color: ‘Optional[str]’ = None)
- __init__(code, name_short=None, name_long=None, description=None, color=None)
- Parameters:
code (int)
name_short (str | None)
name_long (str | None)
description (str | None)
color (str | None)
- Return type:
None
- get_name()
- get_name_long()
- get_name_short()
- translate(translations)
- update(other)
Update this object with attribute values from another LCClass object. Does not update ‘code’ since its assumed to be the unique identifier.
- Parameters:
other (LCClass)
- code: int
- color: str | None = None
- description: str | None = None
- name_long: str | None = None
- name_short: str | None = None
- class te_schemas.land_cover.LCLegend
LCLegend(name: ‘str’, key: ‘List[LCClass]’ = <factory>, nodata: ‘Union[LCClass, None]’ = None)
- __init__(name, key=<factory>, nodata=None)
- add_update_class(lcc)
Checks if the given LCC exists, if True then it updates it else adds it to the ‘key’ collection.
- Parameters:
lcc (LCClass)
- classByCode(code)
- classByNameLong(name_long)
- class_by_attr(attr_name, attr_val)
Returns class in ‘key’ attribute by searching based on attribute name and corresponding value.
- Return type:
LCClass | None
- codes()
- contains_key(code)
- Parameters:
code (int)
- Return type:
bool
- get_multiplier()
Return multiplier for transition calculations
Used to figure out what number to multiply an initial class code by so that when added to a code for the class that a pixel transitions into, the result is the same as if the two codes were concatenated as strings.
This function is retained for backwards-compatibility. The number of classes in a legend in the QGIS plugin is limited 38, and the codes used to represent classes in the transition layers are the position of each class in an ordered list of class codes. This ensures a multiplier greater than 100 is never needed.
- get_ramp_items()
Uses the values, color hex codes, and labels to return a list of style items in the format needed to generate a style for a layer within the QGIS Trends.Earth plugin
- get_transitions_ramp_items(translations={})
Uses the values, color hex codes, and labels to return a list of style items for transtiions among classes in the format needed to generate a style for a layer within the QGIS Trends.Earth plugin
- key_with_nodata()
- orderByCode()
- remove_class(code)
Removes the class with the given code from the ‘key’ collection.
- Parameters:
code (int)
- Return type:
bool
- translate(translations)
- name: str
- class te_schemas.land_cover.LCLegendNesting
LCLegendNesting(parent: ‘LCLegend’, child: ‘LCLegend’, nesting: ‘Dict[int, List[int]]’ = <factory>)
- __init__(parent, child, nesting=<factory>)
- add_update_children(children, parent_lcc)
Add children to the given parent. If parent does not exist it will return False.
- add_update_parent(parent_lcc, children)
- child_class(code)
Gets a child with the given code, else None.
- Parameters:
code (int)
- Return type:
- children_for_parent(parent_lcc)
Get children for the given parent. Returns an empty list if the parent does not exist.
- get_list()
Return the nesting in format needed for GEE
- get_multiplier()
Return multiplier for transition calculations
Used to figure out what number to multiply an initial class code by so that when added to a code for the class that a pixel transitions into, the result is the same as if the two codes were concatenated as strings.
This function is retained for backwards-compatibility. The number of classes in a legend in the QGIS plugin is limited 38, and the codes used to represent classes in the transition layers are the position of each class in an ordered list of class codes. This ensures a multiplier greater than 100 is never needed.
- orphan_children()
Returns a list of orphaned children i.e. without parents defined through nesting.
- Return type:
List[LCClass]
- remove_parent_class(parent_lcc)
Removes parent and corresponding child references in nesting.
- Parameters:
parent_lcc (LCClass)
- Return type:
bool
- translate(translations)
- update_parent(child, new_parent)
- nesting: Dict[int, List[int]]
- class te_schemas.land_cover.LCTransitionDefinitionBase
Base class to define meaning of land cover transitions
Can contain one more more definitions TransitionMatrixBase
- __init__(legend, name, definitions)
- Parameters:
legend (LCLegend)
name (str)
definitions (Any)
- Return type:
None
- get_definition(initial, final)
- get_list(key=None)
Get transition matrix, in GEE format
- get_persistence_list()
Get transition matrix to remap persistence classes, in GEE format
Remap persistence class codes (11, 22), etc., so they are sequential (1, 2, etc.). This makes it easier to assign a clear color ramp in QGIS.
- get_transition_initial_final_key()
Get key linking initial/final classes to their transition codes
First keys are transition codes, values contain a dict of initial/final class
- get_transition_integers_key()
Get key linking initial/final classes to their transition codes
First keys are transition codes, values contain a dict of initial/final class
- validate_transitions(data, **kwargs)
Ensure each transition is represented once and only once
- definitions: Any
- name: str
- class te_schemas.land_cover.LCTransitionDefinitionDeg
Define meaning of land cover transitions in terms of degradation
- __init__(legend, name, definitions)
- Parameters:
legend (LCLegend)
name (str)
definitions (LCTransitionMatrixDeg)
- Return type:
None
- add_update_class(lcc, meaning_str=None)
Adds new or updates existing LCClass object to both the legend and definitions.
- Parameters:
lcc (LCClass)
- remove_class(lcc)
Remove references matching the given land cover class from the legend and definitions.
- Parameters:
lcc (LCClass)
- Return type:
bool
- translate(translations)
- definitions: LCTransitionMatrixDeg
- class te_schemas.land_cover.LCTransitionMatrixBase
Base class to define meaning of land cover transitions
Base class used for transition matrices defining meaning of land cover transitions in terms of degraded/stable/improvement, soil organic carbon change factors, etc.
- __init__(transitions, name)
- Parameters:
transitions (list)
name (str)
- Return type:
None
- meaning_by_transition(initial, final)
Returns the meanings which contain the given land cover classes for initial and final respectively.
- Parameters:
- Return type:
LCTransitionMeaningDeg | None
- meanings_by_class(lcc)
Returns the meanings which contain the given land cover class in the ‘initial’ and/or ‘final’ attributes.
- Parameters:
lcc (LCClass)
- Return type:
List[LCTransitionMeaningDeg]
- name: str
- transitions: list
- class te_schemas.land_cover.LCTransitionMatrixDeg
LCTransitionMatrixDeg(transitions: ‘List[LCTransitionMeaningDeg]’, name: ‘str’)
- __init__(transitions, name)
- Parameters:
transitions (List[LCTransitionMeaningDeg])
name (str)
- Return type:
None
- remove_meanings_by_class(lcc)
Remove LCTransitionMeaningDeg objects containing the given LCClass object. Returns True if at least one meaning was found.
- Parameters:
lcc (LCClass)
- Return type:
bool
- translate(translations)
- update_meaning_classes(lcc)
Update LCClass ‘initial’ and ‘final’ attributes in meaning containing the given class.
- Parameters:
lcc (LCClass)
- transitions: List[LCTransitionMeaningDeg]
- class te_schemas.land_cover.LCTransitionMeaning
LCTransitionMeaning(initial: ‘LCClass’, final: ‘LCClass’, meaning: ‘Any’)
- __init__(initial, final, meaning)
- contains_class(lcc)
Return False if the given class does not exist in the ‘initial’ and/or ‘initial’ attributes, else returns True together with the matching classes.
- Parameters:
lcc (LCClass)
- Return type:
Tuple[bool, list]
- translate(translations)
- update_class(lcc)
Updates the LCClass objects in ‘initial’ or ‘final’ attributes if the given class exists in one or both of these attributes.
- Parameters:
lcc (LCClass)
- meaning: Any