Spatiotemporal analysis

class pylandstats.SpatioTemporalAnalysis(landscapes, metrics=None, classes=None, dates=None, metrics_kws={})[source]
__init__(landscapes, metrics=None, classes=None, dates=None, metrics_kws={})[source]
Parameters:
  • landscapes (list-like) – A list-like of Landscape objects or of strings/file objects/ pathlib.Path objects so that each is passed as the landscape argument of Landscape.__init__
  • metrics (list-like, optional) – A list-like of strings with the names of the metrics that should be computed in the context of this analysis case
  • classes (list-like, optional) – A list-like of ints or strings with the class values that should be considered in the context of this analysis case
  • dates (list-like, optional) – A list-like of ints or strings that label the date of each snapshot of landscapes (for DataFrame indices and plot labels)
  • metrics_kws (dict, optional) – Dictionary mapping the keyword arguments (values) that should be passed to each metric method (key), e.g., to exclude the boundary from the computation of total_edge, metric_kws should map the string ‘total_edge’ (method name) to {‘count_boundary’: False}. The default empty dictionary will compute each metric according to FRAGSTATS defaults.
class_metrics_df

Property that computes the data frame of class-level metrics, which is multi-indexed by the class and date. Once computed, the data frame is cached so further calls to the property just access an attribute and therefore run in constant time.

landscape_metrics_df

Property that computes the data frame of landcape-level metrics, which is indexed by the date. Once computed, the data frame is cached so further calls to the property just access an attribute and therefore run in constant time.

plot_landscapes(cmap=None, legend=True, subplots_kws={}, show_kws={}, subplots_adjust_kws={})

Plots each landscape snapshot in a dedicated matplotlib axis by means of the Landscape.plot_landscape method of each instance

Parameters:
  • cmap (str or ~matplotlib.colors.Colormap, optional) – A Colormap instance
  • legend (bool, optional) – If True, display the legend of the land use/cover color codes
  • subplots_kws (dict, optional) – Keyword arguments to be passed to plt.subplots
  • show_kws (dict, optional) – Keyword arguments to be passed to rasterio.plot.show
  • subplots_adjust_kws (dict, optional) – Keyword arguments to be passed to plt.subplots_adjust
Returns:

fig – The figure with its corresponding plots drawn into its axes

Return type:

matplotlib.figure.Figure

plot_metric(metric, class_val=None, ax=None, metric_legend=True, metric_label=None, fmt='--o', plot_kws={}, subplots_kws={})
Parameters:
  • metric (str) – A string indicating the name of the metric to plot
  • class_val (int, optional) – If provided, the metric will be plotted at the level of the corresponding class, otherwise it will be plotted at the landscape level
  • ax (axis object, optional) – Plot in given axis; if None creates a new figure
  • metric_legend (bool, default True) – Whether the metric label should be displayed within the plot (as label of the y-axis)
  • metric_label (str, optional) – Label of the y-axis to be displayed if metric_legend is True. If the provided value is None, the label will be taken from the settings module
  • fmt (str, default '--o') – A format string for plt.plot
  • plot_kws (dict) – Keyword arguments to be passed to plt.plot
  • subplots_kws (dict) – Keyword arguments to be passed to plt.subplots, only if no axis is given (through the ax argument)
Returns:

ax – Returns the Axes object with the plot drawn onto it

Return type:

axis object