Package: grainscape 1.0.0

grainscape: Landscape Connectivity, Habitat, and Protected Area Networks

Given a landscape resistance surface, creates minimum planar graph (Fall et al. (2007) <doi:10.1007/s10021-007-9038-7>) and grains of connectivity (Galpern et al. (2012) <doi:10.1111/j.1365-294X.2012.05677.x>) models that can be used to calculate effective distances for landscape connectivity at multiple scales. Documentation is provided by several vignettes, and a paper (Chubaty, Galpern & Doctolero (2020) <doi:10.1111/2041-210X.13350>).

Authors:Paul Galpern [aut, cph], Sam Doctolero [aut], Alex M Chubaty [aut, cre]

grainscape_1.0.0.tar.gz
grainscape_1.0.0.zip(r-4.7)grainscape_1.0.0.zip(r-4.6)grainscape_1.0.0.zip(r-4.5)
grainscape_1.0.0.tgz(r-4.6-x86_64)grainscape_1.0.0.tgz(r-4.6-arm64)grainscape_1.0.0.tgz(r-4.5-x86_64)grainscape_1.0.0.tgz(r-4.5-arm64)
grainscape_1.0.0.tar.gz(r-4.7-arm64)grainscape_1.0.0.tar.gz(r-4.7-x86_64)grainscape_1.0.0.tar.gz(r-4.6-arm64)grainscape_1.0.0.tar.gz(r-4.6-x86_64)
grainscape_1.0.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
grainscape/json (API)

# Install 'grainscape' in R:
install.packages('grainscape', repos = c('https://achubaty.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/achubaty/grainscape/issues

Pkgdown/docs site:https://www.alexchubaty.com

Uses libs:
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

habitat-connectivitylandscape-connectivityspatial-graphscpp

6.40 score 20 stars 25 scripts 384 downloads 24 exports 35 dependencies

Last updated from:7beaea2267. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK308
linux-devel-x86_64OK312
source / vignettesOK358
linux-release-arm64OK285
linux-release-x86_64OK304
macos-release-arm64OK173
macos-release-x86_64OK369
macos-oldrel-arm64OK164
macos-oldrel-x86_64OK589
windows-develOK285
windows-releaseOK269
windows-oldrelOK270
wasm-releaseOK210

Exports:corridordistanceexportggGSGOCgraingraphdfgsGOCgsGOCCorridorgsGOCDistancegsGOCPointgsGOCVisualizegsGraphDataFramegsMPGgsMPGstitchMPGpatchFilterplotplotResistanceplotWithResistancepointshowtheme_grainscapethreshold

Dependencies:classclassIntclicpp11DBIe1071farverggplot2gluegtableigraphisobandKernSmoothlabelinglatticelifecyclemagrittrMASSMatrixpkgconfigproxyR6RColorBrewerRcpprlangs2S7scalessfterraunitsvctrsviridisLitewithrwk

Calculating the minimum planar graph
Overview | Finding the Minimum Planar Graph | Technical reference to the MPG engine written in C++ | Terminology | Data Structures | Type Definitions | The Engine Class | Fields/Properties | Methods/Functions | Public Functions | Patch Finding Functions | Linking Functions | Common Functions | Static Functions | How to Use the Engine | Debugging the package C++ code | References

Last update: 2026-07-07
Started: 2016-08-11

Modelling, visualization and analysis with the grainscape package
Visual table of contents | Introduction | Modelling with grainscape | Model 1: The minimum planar graph | Step 1: Preparing the resistance surface | Step 2: Extracting the MPG | Step 3: Quick visualization of the MPG | Step 4: Reporting on the MPG | Step 5: Thresholding the MPG | Step 6: Visualizing a thresholded graph | Step 7: Next steps | Model 2: Patch grains of connectivity | Step 1: Begin with a MPG | Step 2: Exploring the Voronoi tessellation | Step 3: Building GOC models | Step 4: Visualizing a GOC model | Landscape networks with 1D and 2D nodes | Modelling | Planar network with one-dimensional nodes on a Euclidean surface | Make a new resistance raster of 400 by 400 cells | with a coordinate system that corresponds to cells | Assign all values to 1 | Create 20 "random" points representing nodes, | (i.e. the loci of a process of interest) | Represent these on a patch raster | by duplicating the resistance raster and | setting the relevant cells to 1 | Extract the MPG | Plot the result using the quick 'network' visualization | setting and add labels (dodging them by 3 to the upper-right) | Planar network with one-dimensional nodes on a non-Euclidean resistance surface | Add some cost values to the resistance | surface we used in the last step | Here we use random integers >= 2 | Extract the minimum planar graph using the | raster made previously which represents the points only | Plot the result using the quick 'mpgPlot' visualization | This demonstrates the non-linear paths. | Planar network with two-dimensional nodes on a non-Euclidean resistance surface (minimum planar graph) | Load a land cover raster distributed with grainscape | Convert land cover to resistance units | Use an "is-becomes" reclassification | Extract a network using cells = 1 on original raster | as the focal patches or nodes | Plot the minimum planar graph, labelling node 7 and the patches directly | linked to it (its neighbours in the MPG), matching the fragNeighbours | table below. | Visualization | Centroid representation of nodes | Perimeter representation of links | Spatially-explicit representation of links | Characteristics of nodes (weights) | Characteristics of links (weights) | Link thresholding by plotting | Link thresholding to show components | Analysis | Network metrics to assess node importance | Shortest-path distance between nodes | Declare the start and end patchIds | These were identified by plotting the patchIds (see earlier examples) | Find the shortest path between these nodes using | the shortest path through the resistance surface | (i.e. weighted by 'lcpPerimWeight') | Extract the nodes and links of this shortest path | Produce shortest path tables for plotting | Find the distance of the shortest path | Plot shortest path | Scaling landscape networks | Modeling | Scaling resistance surfaces (lattice grains of connectivity) | Scaling networks with two-dimensional nodes (patch grains of connectivity) | Characteristics of grains of connectivity | Corridor analyses at multiple scales | Set coordinates for the start and end of the corridor | Use the default plotting functionality for corridor objects | References

Last update: 2026-07-07
Started: 2017-07-27

Readme and manuals

Help Manual

Help pageTopics
Landscape Connectivity, Habitat, and Protected Area Networksgrainscape-package grainscape
Extract or Replace Parts of an Object$ $,goc-method $,mpg-method $<- $<-,goc-method $<-,mpg-method
Visualize corridors between two points using a grains of connectivity (GOC)corridor corridor,goc-method
The 'corridor' classcorridor-class
Find the grains of connectivity network distancedistance distance,goc,matrix-method distance,goc,numeric-method distance,goc,sf-method
Export spatial data from MPG and GOC modelsexport export,goc-method export,grain-method export,mpg-method
Prepare data in 'MPG' and 'grain' objects for use with 'ggplot2'ggGS ggGS,goc-method ggGS,grain-method ggGS,list-method ggGS,mpg-method ggGS,SpatRaster-method
Produce a grains of connectivity model at multiple scales (patch-based or lattice GOC)GOC GOC,mpg-method
The 'goc' classgoc-class
Extract a grain of connectivity (GOC) tessellation at a given scalegrain grain,goc-method
The 'grain' classgrain-class
Test maps included with 'grainscape'grainscape-maps
Produce a 'data.frame' containing the structure and associated attributesgraphdf graphdf,goc-method graphdf,grain-method graphdf,igraph-method graphdf,list-method graphdf,mpg-method
Extract a minimum planar graph (MPG) model from a landscape resistance surfaceMPG MPG,SpatRaster,numeric-method MPG,SpatRaster,SpatRaster-method
The 'mpg' classmpg-class
Filter out patches smaller than a specified areapatchFilter patchFilter,SpatRaster-method
Plot quick visualizations of 'grainscape' objectsplot,corridor,ANY-method plot,grain,ANY-method plot,mpg,ANY-method
Plot a resistance surface with a consistent colour schemeplotResistance
Show a resistance surface beside a network plotplotWithResistance
Identify the polygons containing locations in grains of connectivity (GOC) tessellationspoint point,goc-method
Show a 'grainscape' objectshow,corridor-method show,goc-method show,grain-method
A 'ggplot2' theme for 'grainscape'theme_grainscape
Produce a minimum planar graph (MPG) at multiple scalesthreshold threshold,mpg-method