Terraflux Terraflux
Download

Landscape metrics

12 operators. Inputs marked required must be connected or given; the others have defaults.

metrics.class#

Landscape metrics of every class, as landscapemetrics and FRAGSTATS: area, share (pland), patches, edge density, aggregation, the patches' metrics summarised (mean, sd, cv...). A table of a row per class, and the map of one metric if asked for.

InputTypeWhat it is
maprequiredrasterthe map of classes (or rasters on disk, by blocks)
OutputTypeWhat it is
tabletableper class: the class and the metrics
mapmapthe metric shown (show) on each class, of a map in memory
SettingTypeWhat it is
metricsanythe metrics (a name or a list: ca, pland, np...; default all of the level)
typetextwithout metrics, those of a type: area and edge, shape, core area, aggregation, diversity, complexity, contrast
extrasboolwithout metrics, FRAGSTATS' that landscapemetrics lacks too
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
block_rowsintegerout of core: the map read by blocks of this many rows (a multiple of 64), the same metrics; rasters on disk of more than 250 million cells always are
showtexta metric of the level to give as a map

metrics.cluster#

Groups of landscapes or zones with similar metrics (landschaft's SpatialSignatureAnalysis.cluster): k-means of the z-scores (or of the first principal components) from numpy's generator, so the same groups as landschaft, or scipy's hierarchical linkages cut into k clusters. The groups are numbered 0.. in order of first appearance.

InputTypeWhat it is
tablerequiredtablethe signatures (metrics.signatures) or any metrics
OutputTypeWhat it is
tabletablethe rows kept (without NA) and their cluster
SettingTypeWhat it is
columnsanythe metrics (default every column but the keys: zone, landscape, class, date...)
methodtextkmeans (default; k-means++ starts, the best of n_init) or a linkage: ward, average, complete, single, centroid, median, weighted
componentsintegercluster the first principal components, not the metrics
n_initintegerk-means: the starts (default 10)
seedintegerk-means: numpy's seed (default 0)
krequiredintegerthe number of clusters

metrics.clustergram#

Clusters for a range of k (Schonlau's clustergram, landschaft's SpatialSignatureAnalysis.clustergram): for every k each row's cluster and the mean of its cluster, the cluster's centre projected on the first principal axis (pca_weighted) or averaged over the metrics.

InputTypeWhat it is
tablerequiredtablethe signatures (metrics.signatures) or any metrics
OutputTypeWhat it is
labelstableper row: its keys and its cluster at each k (k1, k2...)
meanstableper row: its keys and its cluster's mean at each k
SettingTypeWhat it is
columnsanythe metrics (default every column but the keys: zone, landscape, class, date...)
methodtextkmeans (default; k-means++ starts, the best of n_init) or a linkage: ward, average, complete, single, centroid, median, weighted
componentsintegercluster the first principal components, not the metrics
n_initintegerk-means: the starts (default 10)
seedintegerk-means: numpy's seed (default 0)
k_minintegerthe fewest clusters (default 1)
k_maxintegerthe most clusters (default 8)
pca_weightedboolthe means on the first principal axis (default true)

metrics.correlation#

The correlation between the metrics of a table (its columns, over its rows), as landscapemetrics' calculate_correlation: R's cor, Pearson's, Spearman's or Kendall's, the same values. A metric with NA values has NA correlations (but its own, 1). Rows without a class are left out.

InputTypeWhat it is
tablerequiredtablethe metrics, e.g. of metrics.patch or metrics.class
OutputTypeWhat it is
tabletablethe correlation matrix: a row and a column per metric
SettingTypeWhat it is
methodtextpearson (default), spearman or kendall
columnsanythe metrics (default every column but the keys: class, patch, plot_id, size, zone, date...)

metrics.landscape#

Landscape metrics of the whole map, as landscapemetrics and FRAGSTATS: diversity (shdi, sidi...), contagion, edge density, aggregation, the patches' metrics summarised... A table of one row.

InputTypeWhat it is
maprequiredrasterthe map of classes (or rasters on disk, by blocks)
OutputTypeWhat it is
tabletablethe metrics
SettingTypeWhat it is
metricsanythe metrics (a name or a list: ca, pland, np...; default all of the level)
typetextwithout metrics, those of a type: area and edge, shape, core area, aggregation, diversity, complexity, contrast
extrasboolwithout metrics, FRAGSTATS' that landscapemetrics lacks too
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
block_rowsintegerout of core: the map read by blocks of this many rows (a multiple of 64), the same metrics; rasters on disk of more than 250 million cells always are

metrics.nmf#

Non-negative factors of spatial signatures (landschaft's SpatialSignatureAnalysis.nmf): each metric scaled to [0, 1] (constant ones left out), approximated by scores times components, both non-negative (NNDSVDa start, HALS sweeps; scikit-learn's NMF(init="nndsvda", solver="cd")).

InputTypeWhat it is
tablerequiredtablethe signatures (metrics.signatures) or any metrics
OutputTypeWhat it is
scorestableper row: its keys and its factors (NMF1, NMF2...)
componentstableper factor: the weights of the metrics
errornumberthe Frobenius norm of the residual
iterationsintegerthe sweeps made
SettingTypeWhat it is
columnsanythe metrics (default every column but the keys: zone, landscape, class, date...)
factorsrequiredintegerthe number of factors
max_iterintegerthe most sweeps (default 1000)
tolnumberstop when the loss improves by less (relative; 1e-6)

metrics.patch#

Landscape metrics of every patch (the cells of a class connected to one another), as landscapemetrics and FRAGSTATS: area, perimeter, shape, core, nearest neighbour... A table of a row per patch (its class and number, then the metrics), the map of the patches, and the map of one metric if asked for.

InputTypeWhat it is
maprequiredrasterthe map of classes (or rasters on disk, by blocks)
OutputTypeWhat it is
tabletableper patch: its class, its number and the metrics
patchesmapeach cell's patch, by number (of a map in memory, or written to patches_path)
mapmapthe metric shown (show) on each patch, of a map in memory
SettingTypeWhat it is
metricsanythe metrics (a name or a list: ca, pland, np...; default all of the level)
typetextwithout metrics, those of a type: area and edge, shape, core area, aggregation, diversity, complexity, contrast
extrasboolwithout metrics, FRAGSTATS' that landscapemetrics lacks too
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
block_rowsintegerout of core: the map read by blocks of this many rows (a multiple of 64), the same metrics; rasters on disk of more than 250 million cells always are
patches_pathtextrasters on disk by blocks: the GeoTIFF the patches are written to, block by block
showtexta metric of the level to give as a map

metrics.pca#

The principal components of spatial signatures (landschaft's SpatialSignatureAnalysis.pca): the metrics as z-scores (constant ones left out, rows with NA too), their singular value decomposition, each component's largest loading positive.

InputTypeWhat it is
tablerequiredtablethe signatures (metrics.signatures) or any metrics
OutputTypeWhat it is
scorestableper row: its keys and its scores (PC1, PC2...)
loadingstableper component: its share of the variance (explained) and the loadings of the metrics
SettingTypeWhat it is
columnsanythe metrics (default every column but the keys: zone, landscape, class, date...)
componentsintegerthe components kept (default all)

metrics.sample#

Landscape metrics of sample plots, as landscapemetrics' sample_lsm and scale_sample: squares or circles (100 vertices) of a size around points, or polygons as they are. Each plot is cut from the map as terra's crop(mask = TRUE): the window snapped to the nearest cells' edges, the cells the plot touches kept, the others NA; its metrics those of a landscape of its own. Several sizes give a row per size. The % of each plot's area that has cells of the map (its area geodesic when the plots' coordinate system is known, as landscapemetrics).

InputTypeWhat it is
maprequiredrasterthe map of classes (or rasters on disk, read plot by plot)
plotsrequiredvectorpoints (buffers around them) or polygons
OutputTypeWhat it is
tabletableper plot (and size, class or patch): plot_id, size, class, patch, percentage_inside, the metrics
plotsvectorthe plots measured, with plot_id (and size)
SettingTypeWhat it is
metricsanythe metrics (a name or a list: ca, pland, np...; default all of the level)
typetextwithout metrics, those of a type: area and edge, shape, core area, aggregation, diversity, complexity, contrast
extrasboolwithout metrics, FRAGSTATS' that landscapemetrics lacks too
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
leveltextlandscape (default), class or patch
sizeanypoints: the buffer's half side or radius, or a list of them
shapetextpoints: square (default) or circle buffers
id_columntextthe plots' identifiers (default 1, 2...)
all_classesboolclass level: a row (NA) for every class of the map that a plot lacks, and for NA when the map has it
block_rowsintegerout of core: each plot's window read alone from the rasters on disk (always beyond 250 million cells), the map's classes by blocks of this many rows

metrics.series#

Landscape metrics along a series of maps (a layer per date), as pylandstats' SpatioTemporalAnalysis in landschaft: of the whole maps, of zones (polygons), of buffers around points or of square zones tiling the maps (grid). Landscape level: a row per (zone and) date; class level: a row per class, (zone and) date, every class at every date, 0 instead of NA for the area, edge and count metrics of a class absent (fillna).

InputTypeWhat it is
mapsrequiredrasterthe maps of classes, a layer per date (or rasters on disk)
plotsvectorzones (polygons) or points (buffers around them)
OutputTypeWhat it is
tabletableper (class,) (zone and) date: the metrics
SettingTypeWhat it is
metricsanythe metrics (a name or a list: ca, pland, np...; default all of the level)
typetextwithout metrics, those of a type: area and edge, shape, core area, aggregation, diversity, complexity, contrast
extrasboolwithout metrics, FRAGSTATS' that landscapemetrics lacks too
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
leveltextlandscape (default) or class
datesanythe layers' dates (default: their keys, or 1, 2...)
gridnumberzones: squares of this side tiling the maps
sizenumberpoints: the buffer's half side or radius
shapetextpoints: square (default) or circle buffers
fillnaboolclass level: 0 for absent classes' counts (default true)
block_rowsintegerout of core: whole maps read by blocks of this many rows, zones window by window from the rasters on disk (always beyond 250 million cells), the same metrics

metrics.signatures#

Spatial signatures, as pylandstats' SpatialSignatureAnalysis in landschaft: landscapes described by their metrics, a row per zone of a map (polygons, buffers around points or a grid of squares) or per layer of a stack, a column per landscape metric and per class metric and class (pland_11...), in alphabetical order. For metrics.pca, metrics.nmf, metrics.cluster and metrics.clustergram.

InputTypeWhat it is
mapsrequiredrastera map of classes (its zones) or a stack (a row per layer), or rasters on disk
plotsvectorzones (polygons) or points (buffers around them)
OutputTypeWhat it is
tabletableper zone (or landscape): the metrics
SettingTypeWhat it is
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
landscape_metricsanylandscape metrics (a name or a list: shdi, ed...)
class_metricsanyclass metrics, a column per class (pland...)
classesanythe classes of the class metrics (default all)
gridnumberzones: squares of this side tiling the map
sizenumberpoints: the buffer's half side or radius
shapetextpoints: square (default) or circle buffers
fillnabool0 for absent classes' counts and areas (default true)
block_rowsintegerout of core: whole maps read by blocks of this many rows, zones window by window from the rasters on disk (always beyond 250 million cells), the same metrics

metrics.window#

Landscape-level metrics in a moving window, as landscapemetrics' window_lsm: for every cell, the metrics of the landscape the window centred on it covers (cells outside the map are NA). A map per metric, in a stack. Out of core (block_rows, or rasters on disk) by strips of rows with the window's half side above and below, the same maps; those of rasters on disk written to a GeoTIFF, a band per metric.

InputTypeWhat it is
maprequiredrasterthe map of classes (or rasters on disk, by blocks)
OutputTypeWhat it is
mapsrastera map per metric, by its name (on disk for rasters on disk)
SettingTypeWhat it is
metricsanythe metrics (a name or a list: ca, pland, np...; default all of the level)
typetextwithout metrics, those of a type: area and edge, shape, core area, aggregation, diversity, complexity, contrast
extrasboolwithout metrics, FRAGSTATS' that landscapemetrics lacks too
directionsintegerthe patches' connectivity: 8 (default) or 4
count_boundaryboolthe map's boundary counts as edge (default false)
consider_boundaryboolcells at the boundary can be core (default false)
edge_depthintegercore areas: the edge's depth in cells (default 1)
cell_centerboolgyrate: the centroid on a cell of the patch
classes_maxnumberrpr: the most classes there could be
neighbourhoodintegercomplexity metrics: 4 (default) or 8 neighbours
orderedboolcomplexity metrics: ordered pairs (default true)
basetextcomplexity metrics' logarithm: log2 (default), log or log10
conventiontextlandscapemetrics (default) or fragstats (physical edge lengths, disjunct cores' sizes)
search_radiusnumberprox, simi: the search radius (map units)
connect_thresholdnumberconnect: the distance of a connection
boundary_contrastnumberecon, cwed, teci: the weight of edges to NA
contrastanyecon, cwed, teci: [class a, class b, weight] of each edge
similarityanysimi: [class a, class b, weight] of each pair
block_rowsintegerout of core: the map read by blocks of this many rows, the same metrics; rasters on disk of more than 250 million cells always are
windowintegerthe window's side in cells, odd (default 5)
shapetextsquare (default) or circle (the cells within side/2)
pathtextrasters on disk: the GeoTIFF written (default next to the input: name_window5.tif)