Functions for working with the Wetlands Insight Tool (WIT)


WIT_drill(gdf, time[, min_gooddata, …])

The Wetlands Insight Tool run onver an extent covered by a polygon.

animated_timeseries_WIT(ds, df, output_path)

deafrica_tools.wetlands.WIT_drill(gdf, time, min_gooddata=0.85, TCW_threshold=- 0.035, resample_frequency=None, export_csv=None, dask_chunks=None, verbose=False, verbose_progress=False)

The Wetlands Insight Tool run onver an extent covered by a polygon. This function loads FC, WOfS, and Landsat data, and calculates tasseled cap wetness, in order to determine the dominant land cover class within a polygon at each satellite observation.

The output is a pandas dataframe containing a timeseries of the relative fractions of each class at each time-step. This forms the input to produce a stacked line-plot.

Last modified: Oct 2021

  • gdf (geopandas.GeoDataFrame) – The dataframe must only contain a single row, containing the polygon you wish to interrograte.

  • time (tuple) – a tuple containing the time range over which to run the WIT. e.g. (‘2015-01’ , ‘2019-12’)

  • min_gooddata (Float, optional) – A number between 0 and 1 (e.g 0.8) indicating the minimum percentage of good quality pixels required for a satellite observation to be loaded and therefore included in the WIT plot. This number should, at a minimum, be set to 0.80 to limit biases in the result if not resampling the time-series. If resampling the data using the parameter resample_frequency, then setting this number to 0 (or a low float number) is acceptable.

  • TCW_threshold (Int, optional) – The tasseled cap wetness threshold, beyond which a pixel will be considered ‘wet’. Defaults to -0.035.

  • resample_frequency (str) – Option for resampling time-series of input datasets. This option is useful for either smoothing the WIT plot, or because the area of analysis is larger than a scene width and therefore requires composites. Options include any str accepted by xarray.resample(time=). The resampling method used is .max()

  • export_csv (str, optional) – To save the returned pandas dataframe as a .csv file, pass a a location string (e.g. ‘output/results.csv’)

  • dask_chunks (dict, optional) – To lazily load the datasets using dask, pass a dictionary containing the dimensions over which to chunk e.g. {‘time’:-1, ‘x’:250, ‘y’:250}.

  • verbose (bool, optional) – If true, print statements are putput detailing the progress of the tool.

  • verbose_progress (bool, optional) – For use with Dask progress bar


df – A pandas dataframe containing the timeseries of relative fractions of each land cover class (WOfs, FC, TCW)

Return type