Skip to main content

Computing landscape metrics in the Python ecosystem.

Project description

PyPI version fury.io Conda Downloads Documentation Status tests pre-commit.ci status codecov GitHub license

PyLandStats

Open-source library to compute landscape metrics in the Python ecosystem (NumPy, pandas, matplotlib...)

Citation: Bosch M. 2019. "PyLandStats: An open-source Pythonic library to compute landscape metrics". PLOS ONE, 14(12), 1-19. doi.org/10.1371/journal.pone.0225734

Features

  • Read GeoTiff files of land use/cover:

    import pylandstats as pls
    
    ls = pls.Landscape("../data/processed/veveyse-AS18_4.tif")
    ls.plot_landscape(legend=True)
    

    landscape-veveyse

  • Compute pandas data frames of landscape metrics at the patch, class and landscape level:

    class_metrics_df = ls.compute_class_metrics_df(
        metrics=["proportion_of_landscape", "edge_density", "euclidean_nearest_neighbor_mn"]
    )
    class_metrics_df
    
    class_val proportion_of_landscape edge_density euclidean_nearest_neighbor_mn
    1 7.749572 19.102211 309.244705
    2 56.271868 50.599270 229.079970
    3 33.946252 38.167200 253.299859
    4 2.032308 3.722177 552.835154
  • Analyze the spatio-temporal evolution of landscapes:

    import matplotlib.pyplot as plt
    
    input_filepaths = [
        "../data/processed/veveyse-AS97R_4.tif",
        "../data/processed/veveyse-AS09R_4.tif",
        "../data/processed/veveyse-AS18_4.tif",
    ]
    
    sta = pls.SpatioTemporalAnalysis(input_filepaths, dates=["1992", "2004", "2012"])
    sta.plot_metric("contagion")
    

    spatiotemporal-analysis

  • Zonal analysis of landscapes

See the documentation and the pylandstats-notebooks repository for a more complete overview.

Installation

The easiest way to install PyLandStats is with conda:

$ conda install -c conda-forge pylandstats

which will install PyLandStats and all of its dependencies. Alternatively, you can install PyLandStats using pip:

$ pip install pylandstats

Nevertheless, note that in order to define zones by vector geometries in ZonalAnalysis, or in order to use the the BufferAnalysis and SpatioTemporalBufferAnalysis classes, PyLandStats requires geopandas, which cannot be installed with pip. If you already have the dependencies for geopandas installed in your system, you might then install PyLandStats with the geo extras as in:

$ pip install pylandstats[geo]

and you will be able to use the aforementioned features (without having to use conda).

Development install

To install a development version of PyLandStats, you can first use conda to create an environment with all the dependencies and activate it as in:

$ conda create -n pylandstats -c conda-forge geopandas matplotlib-base rasterio scipy openblas
$ conda activate pylandstats

and then clone the repository and use pip to install it in development mode

$ git clone https://github.com/martibosch/pylandstats.git
$ cd pylandstats/
$ pip install -e .

Acknowledgments

  • The computation of the adjacency matrix in transonic has been implemented by Pierre Augier (paugier)
  • Several information theory-based metrics from Nowosad and Stepinski [1] were added by achennu
  • With the support of the École Polytechnique Fédérale de Lausanne (EPFL)
  • The Corine Land Cover datasets used for the test datasets were produced with funding by the European Union

References

  1. Nowosad, J., & Stepinski, T. F. (2019). Information theory as a consistent framework for quantification and classification of landscape patterns. Landscape Ecology, 34(9), 2091-2101.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylandstats-3.0.0rc1.tar.gz (66.8 kB view hashes)

Uploaded Source

Built Distributions

pylandstats-3.0.0rc1-cp311-cp311-musllinux_1_1_x86_64.whl (621.0 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

pylandstats-3.0.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (85.3 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pylandstats-3.0.0rc1-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (87.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.12+ i686 manylinux: glibc 2.17+ i686

pylandstats-3.0.0rc1-cp311-cp311-macosx_10_9_x86_64.whl (81.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pylandstats-3.0.0rc1-cp310-cp310-musllinux_1_1_x86_64.whl (621.0 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

pylandstats-3.0.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (85.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pylandstats-3.0.0rc1-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (87.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ i686 manylinux: glibc 2.17+ i686

pylandstats-3.0.0rc1-cp310-cp310-macosx_10_9_x86_64.whl (81.6 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pylandstats-3.0.0rc1-cp39-cp39-musllinux_1_1_x86_64.whl (621.0 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

pylandstats-3.0.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (85.2 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pylandstats-3.0.0rc1-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (87.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686 manylinux: glibc 2.17+ i686

pylandstats-3.0.0rc1-cp39-cp39-macosx_10_9_x86_64.whl (81.6 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pylandstats-3.0.0rc1-cp38-cp38-musllinux_1_1_x86_64.whl (621.0 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

pylandstats-3.0.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (85.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pylandstats-3.0.0rc1-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl (87.6 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686 manylinux: glibc 2.17+ i686

pylandstats-3.0.0rc1-cp38-cp38-macosx_10_9_x86_64.whl (81.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page