Skip to main content

connectivity: a multi-resolution landscape connectivity algorithm

Build CodeQL PyPI version Python versions Downloads DOI

A multi-resolution landscape connectivity algorithm for calculating Habitat Connectivity (Connected-Habitat), PARC Connectedness and the Bioclimatic Ecosystem Resilience Index (BERI). It combines habitat condition, least-cost paths and dispersal kernels to estimate how much surrounding habitat is accessible across different dispersal scales. The algorithm retains fine spatial detail near each focal cell and represents more distant areas at progressively coarser resolutions, using raster overview layers generated on the fly to make large-landscape analyses efficient. PARC Connectedness additionally incorporates protected-area coverage, while BERI incorporates current and future climate-related compositional similarity to assess ecosystem resilience under climate change. Implemented in Rust with a Python interface, the framework supports biodiversity monitoring and conservation planning. See Valavi et al. (2026) for the full method.

Installation

Install from PyPI

The package is published on PyPI as eco-connectivity (NOTE: pip install connectivity installs an unrelated package):

pip install eco-connectivity

The import name is still connectivity:

from connectivity import connectedness, beri

Install from Source

To build the latest development version from the GitHub repository, install Rust first, then run:

git clone https://github.com/csiro/connectivity.git
cd connectivity
pip install .

Connectivity Analysis

Resolve the bundled example paths once so they can be reused throughout the analysis:

from connectivity import beri, connectedness, example_data_path, resolution_info

condition_file = example_data_path("site_condition")
pa_file = example_data_path("pa_proportion")
current_file = example_data_path("transgrids/1990")
future_files = [
    example_data_path("transgrids/IPS50_45"),
    example_data_path("transgrids/GFD50_85"),
]

To bound the spatial extent of the connectivity calculation, the algorithm limits how far it searches across neighboring cells in the condition raster. The approximate one-sided search reach is computed as: max_reach = outer_window * max(levels) * resolution. For example, with a 1 km resolution raster, a max-level of 32, and an outer_window of 11, the resulting search reach is:

distance = outer_window × max_level × resolution
         = 11 × 32 × 1 km
         = 352 km  

Use resolution_info() to preview how candidate levels will change raster dimensions and approximate search reach before running the analysis:

resolution_info(condition_file, outer_window=9)
File: .../connectivity/data/site_condition.tif
Base raster: 588 x 516 cells (303.41K total)
Base resolution: 0.008333 degrees
CRS: EPSG:4326
Bands: 1
Data type(s): float32
Nodata: -9999.0
Outer window: 9
Small-dimension warning threshold: < 16 cells
Distance note: approximate km values use centre latitude -41.550

Candidate internally generated levels:
  Level    Width   Height      Cells   % base           Resolution            Reach     Reach km  Note
      1      588      516    303.41K 100.000%     0.008333 degrees    0.075 degrees     8.349 km
      2      294      258     75.85K  25.000%      0.01667 degrees     0.15 degrees      16.7 km
      4      147      129     18.96K   6.250%      0.03333 degrees      0.3 degrees      33.4 km
      8       74       65      4.81K   1.585%      0.06667 degrees      0.6 degrees     66.79 km
     16       37       33      1.22K   0.402%       0.1333 degrees      1.2 degrees     133.6 km
     32       19       17        323   0.106%       0.2667 degrees      2.4 degrees     267.2 km
     64       10        9         90   0.030%       0.5333 degrees      4.8 degrees     534.3 km  small grid; review
    128        5        5         25   0.008%        1.067 degrees      9.6 degrees     1.07K km  small grid; review
    256        3        3          9   0.003%        2.133 degrees     19.2 degrees     2.14K km  small grid; review
    512        2        2          4   0.001%        4.267 degrees     38.4 degrees     4.27K km  small grid; review

The default window_mode="circular" uses source-centered circular annuli with fractional area/count support at annulus boundaries. The window_mode="square" option uses the same source-centered fractional construction with square annuli. These modes change indicator values, so compare outputs only between runs that use the same window mode.

Circular multi-resolution windows

Each coloured neighbourhood represents a different raster aggregation level. Fine levels capture nearby cells at higher resolution, while coarser levels extend the search over larger distances. Their contributions are combined into a single graph, in which the least-cost path from the focal cell is calculated for each aggregated cell. See Valavi et al. (2026) for the full method.

Connected Habitat (Connectedness)

To compute connected-habitat (or plain connectedness), you only need a habitat condition raster. Use option argument to generate the connected-habitat from connectedness and input condition with:

  1. connectedness
  2. connectedness * condition
  3. sqrt(connectedness * condition) — geometric mean (default)
connd = connectedness(
    condition_file = condition_file,
    lambdas = [2, 20, 200],
    max_cost = 2.0, 
    window_size = 5, 
    outer_window = 11,
    window_mode = "circular",
    levels = [2, 4, 8, 16, 32], 
    option = 3,
    filename = "./results/connected_habitat.tif"
)

Optional resistance surface

By default the habitat condition raster does double duty: it weights how costly each cell is to move through and supplies the habitat value used in the indicator. Pass an optional resistance_file to decouple these two roles. The resistance raster (values in [0, 1], higher = harder to cross, scaled with resistance_scale) then drives only the least-cost path traversal, while condition still supplies the habitat value:

connd = connectedness(
    condition_file = condition_file,
    resistance_file = resistance_file,   # optional; decoupled movement-cost surface
    resistance_scale = None,             # divide resistance into [0, 1] if needed
    max_cost = 2.0,
    window_mode = "circular",
    levels = [2, 4, 8, 16, 32],
)

The edge weight becomes w = (1.0 - max_cost) * (1 - resistance) + max_cost, so resistance = 0 is free (w = 1) and resistance = 1 is the most costly (w = max_cost). When resistance_file is omitted, condition is used for traversal as before, and the output is unchanged. Cells valid in condition but missing a resistance value fall back to condition for traversal and raise a warning, so the analysis domain is never changed silently. The same resistance_file / resistance_scale arguments are available on beri().

PARC-Connectedness

To compute PARC-connectedness, provide both:

  • a habitat condition raster, and
  • a protected-areas proportion raster.

When pa_file (proportion of protected-areas in each cell) is supplied, the function automatically returns PARC-connectedness instead of standard connectedness.

parcc = connectedness(
    condition_file = condition_file,
    pa_file = pa_file,
    lambdas = [2, 20, 200],
    max_cost = 2.0, 
    window_size = 5, 
    outer_window = 11,
    window_mode = "circular",
    levels = [2, 4, 8, 16, 32], 
    filename = "./results/parc_connectedness.tif"
)

Use pixel_coverage() when you need the proportion of each raster pixel covered by polygon geometry. The calculation is backed by a performant Rust implementation:

from connectivity import pixel_coverage

coverage = pixel_coverage(
    "./data/polygons.gpkg",
    condition_file,
)

Bioclimatic Ecosystem Resilience Index (BERI)

To compute BERI, you must provide:

  • a condition raster
  • current GDM transgrids
  • one or more future transgrids scenarios (as a list)
beris = beri(
    condition_file = condition_file,
    current_file = current_file,
    future_files = future_files,
    lambdas = [2, 20, 200], 
    max_cost = 2.0, 
    window_size = 5, 
    outer_window = 11,
    window_mode = "circular",
    levels = [2, 4, 8, 16, 32],
    filename = "./results/berri.tif"
)

Running Analysis with Tiles

To run the model using tiles, create a rectangular tile polygon as a GeoDataFrame and pass it to the polygon_mask argument. This limits data loading to only the portion required for the tile, i.e. the output core plus the internally buffered neighborhood.

Use make_tile() to generate non-overlapping output-core tiles whose internal boundaries align with the coarsest aggregation level. This is preferred over creating overlap-expanded tile polygons externally. Be sure to set closed_border = False (the default) so that neighborhood information is included around each tile core.

from connectivity import connectedness, make_tile

levels = [2, 4, 8, 16, 32]

tile_id = 0
tile_poly = make_tile(
    raster_file = condition_file,
    nrows = 4,
    ncols = 4,
    tile_id = tile_id,
    align_to = max(levels),
)

connd = connectedness(
    condition_file = condition_file,
    polygon_mask = tile_poly,
    closed_border = False,
    margin_px = 32,
    lambdas = [2, 20, 200],
    max_cost = 2.0, 
    window_size = 5, 
    outer_window = 11,
    window_mode = "circular",
    levels = levels, 
    option = 1,
    filename = f"./results/connected_habitat_tile_{tile_id}.tif"
)

For large, uneven workloads, use balanced tiles:

tile_poly = make_tile(
    raster_file = condition_file,
    nrows = 4,
    ncols = 4,
    tile_id = tile_id,
    align_to = max(levels),
    balanced = True,
    io_weight = 0.1,
)

Balanced tiling uses a deterministic raster-mask cost estimate while preserving the same align_to boundary alignment. It is useful for global rasters where some tiles contain mostly ocean or nodata and others contain many valid land pixels. Use balanced = False (the default) when equal aligned tiles are enough. When balanced = False, io_weight is ignored.

Citation

To cite connectivity library in publications and reports, please use:

Valavi, R., Mokany, K., Ware, C., Vickers, M., Giljohann, K. M., & Ferrier, S. (2026). A scalable multi-resolution framework for connectivity-based biodiversity indicators. EcoEvoRxiv. https://doi.org/10.32942/X2S68V

Back to top!

Metadata

Release files for eco-connectivity 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eco-connectivity 2.3.0
File Size Uploaded Provenance Actions
eco_connectivity-2.3.0.tar.gz 35.0 MB With provenance Details for eco_connectivity-2.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for eco-connectivity 2.3.0
File Actions
eco_connectivity-2.3.0-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details for eco_connectivity-2.3.0-cp38-abi3-win_amd64.whl
eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_x86_64.whl CPython 3.8 abi3 Linux glibc 2.28+ x86-64 Details for eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_x86_64.whl
eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_aarch64.whl CPython 3.8 abi3 Linux glibc 2.28+ ARM64 Details for eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_aarch64.whl
eco_connectivity-2.3.0-cp38-abi3-macosx_10_12_universal2.whl CPython 3.8 abi3 macOS 10.12+ universal2 (ARM64, x86-64) Details for eco_connectivity-2.3.0-cp38-abi3-macosx_10_12_universal2.whl

Total release size: 167.4 MB

Release files / eco_connectivity-2.3.0.tar.gz

Download URL eco_connectivity-2.3.0.tar.gz
Size 35.0 MB
Tags Source
SHA-256 checksum
How to use checksums
cbca60964d9ef9ee1229a19c00e7078420e36f0b0f69ffee1ec1dd6f98fb6bd9
BLAKE2b-256 checksum
How to use checksums
e8c1859a15c833ad0c8f89724d9ec4572b3124e77ff0f29ac0c69f6097d9a86a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / eco_connectivity-2.3.0-cp38-abi3-win_amd64.whl

Download URL eco_connectivity-2.3.0-cp38-abi3-win_amd64.whl
Size 32.8 MB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dc79435cc842987aeaaefcb2bcbb22f7a7bbddf4a82819a016c0d886c68f5123
BLAKE2b-256 checksum
How to use checksums
6768a846b2a37da0b6a904774ac0adbeb4b5fd5bc176623a5ee0af02deceb246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_x86_64.whl

Download URL eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_x86_64.whl
Size 33.3 MB
Tags CPython 3.8 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
0a5485f8a9eb3ac89bb423eb17f1a6037dc2fe40b689113edc1f013e0cbc9f73
BLAKE2b-256 checksum
How to use checksums
5c019d9dc53030dc71c3ebc9e45bbcf2864d35d72f2b5e7b00c465dd3d78a486
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_aarch64.whl

Download URL eco_connectivity-2.3.0-cp38-abi3-manylinux_2_28_aarch64.whl
Size 33.2 MB
Tags CPython 3.8 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
a9c39f97ad70a753954f1ea39169b068b3b9a3d6bc5cd8261ec30d5817dd2f6b
BLAKE2b-256 checksum
How to use checksums
57c5529a79d38aa40465e354fd18098cc5657b8bbd09d5fcb74227f7d7b8b08e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / eco_connectivity-2.3.0-cp38-abi3-macosx_10_12_universal2.whl

Download URL eco_connectivity-2.3.0-cp38-abi3-macosx_10_12_universal2.whl
Size 33.2 MB
Tags CPython 3.8 abi3 macOS 10.12+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
080a2470ed9150b25d308231a3c4c50ee08458961eebcc9eeb49ccb2ff21d92d
BLAKE2b-256 checksum
How to use checksums
d8afecdd52d0719a23bd79eadf3b24aa489a6d574d81c2cecdbdacff67dccb8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for eco-connectivity 2.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for eco_connectivity-2.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page