Skip to main content

Open-source Python library to compute landscape metrics

Project description

PyPI version Anaconda-Server Badge Documentation Status Build Status Coverage Status GitHub license


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". Preprint available at bioRxiv.


Read GeoTiff files of land use/cover

import pylandstats as pls

ls = pls.read_geotiff('data/vaud_g100_clc00_V18_5.tif')



Compute pandas DataFrames of landscape metrics at the patch, class and landscape level

patch_metrics_df = ls.compute_patch_metrics_df()
patch_id class_val area perimeter perimeter_area_ratio shape_index fractal_dimension euclidean_nearest_neighbor
0 1 115 10600 92.17 2.409 1.130 1431.782
1 1 13 2600 200.00 1.625 1.100 223.607
2 1 2 600 300.00 1.000 1.012 223.607
3 1 69 6000 86.96 1.765 1.088 316.228
4 1 76 8800 115.79 2.444 1.137 316.228
class_metrics_df = ls.compute_class_metrics_df(metrics=['proportion_of_landscape', 'edge_density'])
class_val proportion_of_landscape edge_density
1 7.702 4.459
2 92.298 4.459

Also analyze the spatio-temporal evolution of the landscape:

input_fnames = [

sta = pls.SpatioTemporalAnalysis(
    input_fnames, metrics=[
    ], classes=[1], dates=[2000, 2006, 2012], 

fig, axes = sta.plot_metrics(
    metrics=['proportion_of_landscape', 'edge_density', 'fractal_dimension_am'],
fig.suptitle('Class-level metrics (urban)')


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


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 the BufferAnalysis and SpatioTemporalBufferAnalysis classes make use of 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 BufferAnalysis and SpatioTemporalBufferAnalysis classes (without having to use conda).


  • 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-1.1.0.tar.gz (42.7 kB view hashes)

Uploaded Source

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