lsapy.LandSuitabilityAnalysis.run#
- LandSuitabilityAnalysis.run(suitability_type='overall', agg_methods='mean', by_category=None, keep_vars=True, inplace=False, **kwargs)[source]#
Run the land suitability analysis.
- Parameters:
suitability_type (
str) – The type of suitability to compute. Options are ‘criteria’, ‘category’, or ‘overall’. The default is ‘overall’.agg_methods (
str|dict[str,str]) – The aggregation method to use for the suitability computation. If a string, it applies the same method to compute the category and overall suitability. If a dictionary, the keys ‘category’ and ‘overall’ are used to specify the aggregation method to use for each type of suitability. The default is ‘mean’.by_category (
bool|None) – If True, compute the overall suitability aggregating categories suitability. If False, use the criteria suitability. The default behavior uses categories suitability if categories are found in criteria, otherwise it uses the criteria suitability.keep_vars (
bool|None) – If True, return all the variables computed as part of the computation process, otherwise return only the data defined by the suitability_type. The default is True.inplace (bool, optional) – If True, compute the suitability in place. The default is False.
**kwargs (dict) – Additional keyword arguments to pass to the suitability criteria compute method.
- Returns:
If inplace is False, return the computed suitability as a Dataset. If inplace is True, return None.
- Return type:
None | xr.Dataset
Notes
To avoid biais in LSA categories outputs, it was decided to apply the same aggregation method to all categories.
Examples
Let first define the
SuitabilityCriteria(we use xclim package for the GDD computation):>>> from lsapy.utils import open_data >>> import lsapy.standardize as lstd >>> from xclim.indicators.atmos import growing_degree_days
>>> drainage = open_data("land", variables="drainage") >>> tas = open_data("climate", variables="tas") >>> sc = { ... "drainage_class": SuitabilityCriteria( ... name="drainage_class", ... long_name="Drainage Class Suitability", ... weight=3, ... category="soilTerrain", ... indicator=drainage, ... func=lstd.discrete, ... fparams={"rules": {0: 0, 1: 0.1, 2: 0.5, 3: 0.9, 4: 1}}, ... ), ... "growing_degree_days": SuitabilityCriteria( ... name="growing_degree_days", ... long_name="Growing Degree Days Suitability", ... weight=1, ... category="climate", ... indicator=growing_degree_days(tas, thresh="10 degC", freq="YS-JUL"), ... func=lstd.vetharaniam2022_eq5, ... fparams={"a": -1.41, "b": 801}, ... ), ... }
Now we can define the
LandSuitabilityAnalysis:>>> lsa = LandSuitabilityAnalysis( ... land_use="land_use", ... short_name="land_suitability_analysis", ... long_name="Land Suitability Analysis", ... criteria=sc, ... )
The land suitability analysis can now be run:
>>> lsa.run(inplace=True)