Skip to main content

Open-source Python library to compute landscape metrics

Project description

PyPI version fury.io Conda Downloads Documentation Status Build Status Coverage Status GitHub license

PyLandStats

Open-source Pythonic library to compute landscape metrics within the PyData stack (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.read_geotiff('data/vaud_g100_clc00_V18_5.tif')
    
    ls.plot_landscape(legend=True)
    

    landscape-vaud

  • 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'])
    class_metrics_df
    
    class_val proportion_of_landscape edge_density
    1 7.702 4.459
    2 92.298 4.459
  • Analyze the spatio-temporal evolution of landscapes:

    input_fnames = [
        'data/vaud_g100_clc00_V18_5.tif',
        'data/vaud_g100_clc06_V18_5a.tif',
        'data/vaud_g100_clc12_V18_5a.tif'
    ]
    
    sta = pls.SpatioTemporalAnalysis(
        input_fnames, metrics=[
            'proportion_of_landscape',
            'edge_density',
            'fractal_dimension_am',
            'landscape_shape_index',
            'shannon_diversity_index'
        ], classes=[1], dates=[2000, 2006, 2012], 
    )
    
    fig, axes = plt.subplots(1, 3, figsize=(15, 5))
    for metric, ax in zip(
        ['proportion_of_landscape', 'edge_density', 'fractal_dimension_am'], axes):
        sta.plot_metric(metric, class_val=1, ax=ax)
    fig.suptitle('Class-level metrics (urban)')
    

    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).

Acknowledgments

  • The computation of the adjacency matrix in transonic has been implemented by Pierre Augier (paugier).
  • 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

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-2.2.1.tar.gz (48.2 kB view details)

Uploaded Source

File details

Details for the file pylandstats-2.2.1.tar.gz.

File metadata

  • Download URL: pylandstats-2.2.1.tar.gz
  • Upload date:
  • Size: 48.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.11

File hashes

Hashes for pylandstats-2.2.1.tar.gz
Algorithm Hash digest
SHA256 5b8ea9d926ac6e780b747a865486e8cb6c41097dc588a9c85e8982f487f1073e
MD5 1a028dd745cd0448d13d159b8efc83d1
BLAKE2b-256 b33170b89aa50c7381a6931c3c9f6ae9e27964d6298efbd39c51ebcc194cdd0d

See more details on using hashes here.

Supported by

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