Terraflux Terraflux
Download

Open-source software for landscape ecology

See a landscape change, cell by cell, and know why.

Terraflux is a free desktop application and command line for habitat patterns, connectivity, spatial prioritization, species distributions and land change simulation. You build an analysis by connecting nodes, and it gives the same numbers as the tools you would cite.

For Windows, macOS and Linux. GDAL included, nothing else to install. Free under the GPL.

Simulated land use step 0
Forest Farming Converted in this run Water
A cellular automaton in the spirit of Dinamica EGO's Expander, running in your browser: farming spreads into the forest next to it, where the land suits it best.

The same numbers as the tools you cite

Terraflux re-implements established methods from their publications and source code, and its test suite checks each one against the reference implementation, most of them to the last bit. A reviewer who knows FRAGSTATS or Zonation will find the same results.

GuidosToolboxMSPA, fragmentation, accountingVogt & Riitters 2017
landscapemetricsPatch, class and landscape metricsHesselbarth et al. 2019
ConeforHabitat graphs, the PC and IIC indicesSaura & Torné 2009
Circuitscape and OmniscapeCurrent flow through resistanceMcRae et al. 2008
gdistanceLeast-cost and random-walk distancesvan Etten 2017
Zonation 5Priority ranking of a landscapeMoilanen et al. 2022
MarxanReserve selection by simulated annealingBall et al. 2009
InVESTCarbon, habitat quality, water yield and sedimentNelson et al. 2009
MaxNet and ENMevalSpecies distribution modelsPhillips et al. 2017
BiodiverseEndemism and phylogenetic diversityLaffan et al. 2010
Dinamica EGOWeights of evidence, Expander and PatcherSoares-Filho et al. 2002
CLUE-S, lulcc and PLUSDemand-driven land allocationVerburg et al. 2002; Liang et al. 2021

An analysis is a graph you can read

Each step is a node: read a map, reclassify it, run MSPA, plot the result. You connect an output to an input, and Terraflux checks that the two fit. Change a setting and only what depends on it runs again, so the map updates while you think.

  • Every node carries a note saying why it is there, so a model explains itself to a colleague.
  • The graph is a small text file: keep it under version control and publish it with your paper.
  • The same file runs in the application, from the command line, on a cluster and from Python.
Learn the basics in the first tutorials
landscape (nlm.random_cluster)landscapenlm.random_clustermapmap: maprows = 300columns = 300p = 0.55weights = [0.3, 0.15, 0.55]+ 1 more settingsforest (raster.reclassify)forestraster.reclassifymap: mapmapmapmap: maprules = "3 -> 2 …"mspa (landscape.mspa)mspalandscape.mspamap: mapmapmapmap: mapedge_width = 1connectivity = 8plot (view.plot)plotview.plotvalue: rastervalueshownshown: anytitle = "MSPA"
The Terraflux window: the model graph, the selected node's settings and its map

Ask for the analysis, watch it being built

Connect an AI assistant to Terraflux and describe what you want in plain words. The assistant adds the nodes, connects and sets them, checks the model and runs it, and the graph grows on your canvas as it works. Undo any step with ctrl+Z, or change it by hand.

  • Every edit passes the same checks as yours: a connection that does not fit is refused, with the reason.
  • Terraflux runs on your computer. The assistant receives the model and the summaries it asks for, not your maps.
  • The result is an ordinary model file that runs again without the assistant.
Connect an assistant

Read landcover.tif, where class 3 is forest, run MSPA with an edge width of 2 and open it in Terraflux.

  1. new_modelfragmentation.toml
  2. add_noderead · raster.read
  3. add_nodeforest · raster.reclassify
  4. add_nodemspa · landscape.mspa
  5. check_modelThe model can run.
  6. open_in_appthe canvas follows every edit

Claude DesktopClaude CodeGemini CLICodexany MCP client

From a first map to a full study

436 operators in eighteen fields, each with tutorials that start from the idea behind the method and the papers that introduced it, and end with the graph that runs it.

Getting started Open and look at maps and vectors, reproject and resample them, save them, and build your first graph. 7 tutorials Building models Map algebra, stacks, loops, groups, submodels and plugins: the pieces every model is made of. 10 tutorials Habitat patterns GuidosToolbox's morphological spatial pattern analysis: cores, edges, bridges and corridors. 4 tutorials Fragmentation How fragmented a habitat is at many scales: density, connectivity, contagion and entropy. 3 tutorials Landscape metrics FRAGSTATS' and landscapemetrics' metrics per patch, class and landscape, in windows and signatures. 7 tutorials Habitat networks Habitat as a graph: Conefor's connectivity indices, ProtConn and the importance of each patch. 6 tutorials Circuit connectivity Circuitscape and Omniscape: movement as electrical current through a landscape of resistance. 4 tutorials Surface metrics Terrain and continuous surfaces: slope, curvature, roughness, texture, landforms and protected hilltops. 4 tutorials Terrain hydrology How water moves over a terrain: depressions, flow directions and accumulation, streams, watersheds, HAND, wetness indices and SWAT+. 4 tutorials Grid distances Least-cost paths, cost distances and random walks across a landscape, as R's gdistance. 2 tutorials Distance and restoration Distances, ecological intactness and where restoration does most for species. 6 tutorials Change detection What changed between two maps, how fast and how intensely: transitions, intensity analysis and diffeR. 4 tutorials Neutral landscape models Landscapes drawn by chance, to test methods and to ask what pattern alone would give. 2 tutorials Biodiversity analysis Biodiverse's analyses: richness, endemism, phylogenetic diversity and clusters of regions. 3 tutorials Spatial prioritization Zonation, Marxan, integer linear programming and multi-action planning: where to protect, restore and act. 7 tutorials Species distributions From GBIF records to a distribution model, its evaluation and its projection to other climates. 7 tutorials Animal movement GPS tracks from Movebank read, cleaned and measured, resampled into steps and summarised, and turned into the data of step selection functions, as move2 and amt do. 5 tutorials Ecosystem services InVEST's models: carbon storage, habitat quality, annual and seasonal water yield, sediment and nutrient retention, and crop pollination. 8 tutorials Land change simulation Dinamica EGO, CLUE-S, PLUS and agents: calibrate, simulate and validate the future of a landscape. 28 tutorials Uncertainty Monte Carlo and the propagation of uncertainty through a model. 1 tutorial Large data and batches Rasters larger than memory and the same analysis over hundreds of files. 2 tutorials

From a laptop to a cluster, without rewriting anything

Run fifty replicates on the cores of your laptop, lend the lab's computers to a calibration with a pairing code, or send five hundred scenarios to your university's Slurm cluster. The model stays the same file. Maps larger than memory run in tiles, with the same result whatever the number of machines.

Read the guide to parallel and distributed computing
  1. Your computerMost cores, a quarter left freeterraflux submit model.toml --replicates 50
  2. The lab's computersFound on the network, joined by a codeterraflux worker --code K7QM-2XPA-9DTE
  3. A cluster or the cloudSlurm or SSH, saved onceterraflux submit model.toml --replicates 500 --on hpc

Get Terraflux

The installers bring GDAL and every library Terraflux needs.

Windows

Windows 10 and 11, 64-bit

Installer (.msi) Other formats

macOS

Apple silicon (M1 or later)

Disk image (.dmg) Other formats

Linux

x86-64, glibc 2.39 or newer (Ubuntu 24.04+, Debian 13+, Fedora 40+, Arch)

Debian / Ubuntu (.deb) Other formats

Open science, open source

Terraflux is free software under the GPL. Its methods are documented with the papers they come from, its results are tested against the reference implementations, and every model is a text file that can be published beside the paper that used it.

How to cite Terraflux
@software{terraflux,
  author  = {Lacerda, Eduardo},
  title   = {Terraflux: landscape ecology and land change
             modelling from a laptop to a cluster},
  version = {1.41.0},
  year    = {2026},
  url     = {https://github.com/sacridini/terraflux},
  license = {GPL-3.0-or-later}
}