ClassStat calculates the class statistics for patch
types identified in a matrix of data or in a raster of
class 'asc' (SDMTools & adehabitat packages), 'RasterLayer'
(raster package) or 'SpatialGridDataFrame' (sp package).
a matrix of data with patches identified as
classes (unique integer values) as e.g., a binary
lanscape of a species distribution or a vegetation map.
Matrix can be a raster of class 'asc' (adehabitat
package), 'RasterLayer' (raster package) or
'SpatialGridDataFrame' (sp package)
cellsize
cell size (in meters) is a single value
representing the width/height of cell edges (assuming
square cells)
bkgd
the background value for which statistics
will not be calculated
latlon
boolean value representing if the data is
geographic. If latlon == TRUE, matrix must be of class
'asc', 'RasterLayer' or 'SpatialGridDataFrame'
a particular patch type
from the original input matrix (mat).
n.patches
the number of patches of a particular
patch type or in a class.
total.area
the sum of the
areas (m2) of all patches of the corresponding patch type.
prop.landscape
the proportion of the total lanscape
represented by this class
patch.density
the numbers
of patches of the corresponding patch type divided by total
landscape area (m2).
total.edge
the total edge
length of a particular patch type.
edge.density
edge length on a per unit area basis
that facilitates comparison among landscapes of varying
size.
landscape.shape.index
a standardized measure
of total edge or edge density that adjusts for the size of
the landscape.
largest.patch.index
largest patch
index quantifies the percentage of total landscape area
comprised by the largest patch.
mean.patch.area
average area of patches.
sd.patch.area
standard deviation of patch areas.
min.patch.area
the minimum patch area of the total
patch areas.
max.patch.area
the maximum patch area
of the total patch areas.
perimeter.area.frac.dim
perimeter-area fractal
dimension equals 2 divided by the slope of regression line
obtained by regressing the logarithm of patch area (m2)
against the logarithm of patch perimeter (m).
mean.perim.area.ratio
the mean of the ratio patch
perimeter. The perimeter-area ratio is equal to the ratio
of the patch perimeter (m) to area (m2).
sd.perim.area.ratio
standard deviation of the ratio
patch perimeter.
min.perim.area.ratio
minimum
perimeter area ratio
max.perim.area.ratio
maximum
perimeter area ratio.
mean.shape.index
mean of
shape index
sd.shape.index
standard deviation of
shape index.
min.shape.index
the minimum shape
index.
max.shape.index
the maximum shape index.
mean.frac.dim.index
mean of fractal dimension
index.
sd.frac.dim.index
standard deviation of
fractal dimension index.
min.frac.dim.index
the
minimum fractal dimension index.
max.frac.dim.index
the maximum fractal dimension
index.
total.core.area
the sum of the core areas of
the patches (m2).
prop.landscape.core
proportional
landscape core
mean.patch.core.area
mean patch core
area.
sd.patch.core.area
standard deviation of
patch core area.
min.patch.core.area
the minimum
patch core area.
max.patch.core.area
the maximum
patch core area.
prop.like.adjacencies
calculated
from the adjacency matrix, which shows the frequency with
which different pairs of patch types (including like
adjacencies between the same patch type) appear
side-by-side on the map (measures the degree of aggregation
of patch types).
aggregation.index
computed simply
as an area-weighted mean class aggregation index, where
each class is weighted by its proportional area in the
landscape.
lanscape.division.index
based on the
cumulative patch area distribution and is interpreted as
the probability that two randomly chosen pixels in the
landscape are not situated in the same patch
splitting.index
based on the cumulative patch area
distribution and is interpreted as the effective mesh
number, or number of patches with a constant patch size
when the landscape is subdivided into S patches, where S is
the value of the splitting index.
effective.mesh.size
equals 1 divided by the total
landscape area (m2) multiplied by the sum of patch area
(m2) squared, summed across all patches in the landscape.
patch.cohesion.index
measures the physical
connectedness of the corresponding patch type.
McGarigal, K., S. A. Cushman, M. C. Neel, and E. Ene. 2002.
FRAGSTATS: Spatial Pattern Analysis Program for Categorical
Maps. Computer software program produced by the authors at
the University of Massachusetts, Amherst. Available at the
following web site:
www.umass.edu/landeco/research/fragstats/fragstats.html
See Also
PatchStat, ConnCompLabel
Examples
#define a simple binary matrix
tmat = { matrix(c( 0,0,0,1,0,0,1,1,0,1,
0,0,1,0,1,0,0,0,0,0,
0,1,NA,1,0,1,0,0,0,1,
1,0,1,1,1,0,1,0,0,1,
0,1,0,1,0,1,0,0,0,1,
0,0,1,0,1,0,0,1,1,0,
1,0,0,1,0,0,1,0,0,1,
0,1,0,0,0,1,0,0,0,1,
0,0,1,1,1,0,0,0,0,1,
1,1,1,0,0,0,0,0,0,1),nr=10,byrow=TRUE) }
#do the connected component labelling
ccl.mat = ConnCompLabel(tmat)
ccl.mat
image(t(ccl.mat[10:1,]),col=c('grey',rainbow(length(unique(ccl.mat))-1)))
#calculate the patch statistics
ps.data = PatchStat(ccl.mat)
ps.data
#calculate the class statistics
cl.data = ClassStat(tmat)
cl.data
#identify background data is 0
cl.data = ClassStat(tmat,bkgd=0)
cl.data
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(SDMTools)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/SDMTools/ClassStat.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ClassStat
> ### Title: Landscape Class Statistics
> ### Aliases: ClassStat
>
> ### ** Examples
>
> #define a simple binary matrix
> tmat = { matrix(c( 0,0,0,1,0,0,1,1,0,1,
+ 0,0,1,0,1,0,0,0,0,0,
+ 0,1,NA,1,0,1,0,0,0,1,
+ 1,0,1,1,1,0,1,0,0,1,
+ 0,1,0,1,0,1,0,0,0,1,
+ 0,0,1,0,1,0,0,1,1,0,
+ 1,0,0,1,0,0,1,0,0,1,
+ 0,1,0,0,0,1,0,0,0,1,
+ 0,0,1,1,1,0,0,0,0,1,
+ 1,1,1,0,0,0,0,0,0,1),nr=10,byrow=TRUE) }
>
> #do the connected component labelling
> ccl.mat = ConnCompLabel(tmat)
> ccl.mat
[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,] 0 0 0 1 0 0 2 2 0 3
[2,] 0 0 1 0 1 0 0 0 0 0
[3,] 0 1 NA 1 0 1 0 0 0 4
[4,] 1 0 1 1 1 0 1 0 0 4
[5,] 0 1 0 1 0 1 0 0 0 4
[6,] 0 0 1 0 1 0 0 4 4 0
[7,] 4 0 0 1 0 0 4 0 0 4
[8,] 0 4 0 0 0 4 0 0 0 4
[9,] 0 0 4 4 4 0 0 0 0 4
[10,] 4 4 4 0 0 0 0 0 0 4
> image(t(ccl.mat[10:1,]),col=c('grey',rainbow(length(unique(ccl.mat))-1)))
>
> #calculate the patch statistics
> ps.data = PatchStat(ccl.mat)
> ps.data
patchID n.cell n.core.cell n.edges.perimeter n.edges.internal area core.area
1 0 60 1 122 118 60 1
2 1 17 0 60 8 17 0
3 2 2 0 6 2 2 0
4 3 1 0 4 0 1 0
5 4 19 0 54 22 19 0
perimeter perim.area.ratio shape.index frac.dim.index core.area.index
1 122 2.033333 3.812500 1.669487 0.01666667
2 60 3.529412 3.333333 1.911646 0.00000000
3 6 3.000000 1.000000 1.169925 0.00000000
4 4 4.000000 1.000000 NaN 0.00000000
5 54 2.842105 3.000000 1.767868 0.00000000
>
> #calculate the class statistics
> cl.data = ClassStat(tmat)
> cl.data
class n.patches total.area prop.landscape patch.density total.edge
1 0 1 60 0.6060606 0.01010101 122
2 1 4 39 0.3939394 0.04040404 124
edge.density landscape.shape.index largest.patch.index mean.patch.area
1 1.232323 3.812500 0.6060606 60.00
2 1.252525 4.769231 0.1919192 9.75
sd.patch.area min.patch.area max.patch.area perimeter.area.frac.dim
1 NA 60 60 4.068988
2 9.569918 1 19 6.415815
mean.perim.area.ratio sd.perim.area.ratio min.perim.area.ratio
1 2.033333 NA 2.033333
2 3.342879 0.527555 2.842105
max.perim.area.ratio mean.shape.index sd.shape.index min.shape.index
1 2.033333 3.812500 NA 3.8125
2 4.000000 2.083333 1.258306 1.0000
max.shape.index mean.frac.dim.index sd.frac.dim.index min.frac.dim.index
1 3.812500 1.669487 NA 1.669487
2 3.333333 1.616480 0.3933526 1.169925
max.frac.dim.index total.core.area prop.landscape.core mean.patch.core.area
1 1.669487 1 0.01010101 1
2 1.911646 0 0.00000000 0
sd.patch.core.area min.patch.core.area max.patch.core.area
1 NA 1 1
2 0 0 0
prop.like.adjacencies aggregation.index lanscape.division.index
1 0.3259669 56.73077 0.6326905
2 0.1142857 24.61538 0.9331701
splitting.index effective.mesh.size patch.cohesion.index
1 2.72250 36.363636 7.833718
2 14.96336 6.616162 6.809548
>
> #identify background data is 0
> cl.data = ClassStat(tmat,bkgd=0)
> cl.data
class n.patches total.area prop.landscape patch.density total.edge
1 1 4 39 0.3939394 0.04040404 124
edge.density landscape.shape.index largest.patch.index mean.patch.area
1 1.252525 4.769231 0.1919192 9.75
sd.patch.area min.patch.area max.patch.area perimeter.area.frac.dim
1 9.569918 1 19 6.415815
mean.perim.area.ratio sd.perim.area.ratio min.perim.area.ratio
1 3.342879 0.527555 2.842105
max.perim.area.ratio mean.shape.index sd.shape.index min.shape.index
1 4 2.083333 1.258306 1
max.shape.index mean.frac.dim.index sd.frac.dim.index min.frac.dim.index
1 3.333333 1.61648 0.3933526 1.169925
max.frac.dim.index total.core.area prop.landscape.core mean.patch.core.area
1 1.911646 0 0 0
sd.patch.core.area min.patch.core.area max.patch.core.area
1 0 0 0
prop.like.adjacencies aggregation.index lanscape.division.index
1 0.1142857 24.61538 0.9331701
splitting.index effective.mesh.size patch.cohesion.index
1 14.96336 6.616162 6.809548
>
>
>
>
>
> dev.off()
null device
1
>