batty {SpatEntropy} | R Documentation |
Batty's entropy.
Description
This function computes Batty's spatial entropy, following Batty (1976), see also Altieri et al (2017 and following)
(references are under the topic SpatEntropy
).
Usage
batty(
data,
category = 1,
cell.size = 1,
partition = 10,
win = NULL,
rescale = T,
plotout = T
)
Arguments
data |
If data are lattice, a data matrix, which can be numeric, factor, character, ...
If the dataset is a point pattern, |
category |
A single value matching the data category of interest for computing Batty's entropy. Default to 1. If the dataset is an unmarked point pattern, this argument must not be changed from the default. In the plot, only data belonging to the selected category are displayed. |
cell.size |
A single number or a vector of length two, only needed if data are lattice. It gives the length of the side of each pixel; if the pixel is rectangular, the first number gives the horizontal side and the second number gives the vertical side. Default to 1. Ignored if data are points. |
partition |
Input defining the partition into subareas. If an integer, it defines the
number of sub-areas that are randomly generated by areapart; if a two column matrix
with coordinates, they are the centroids of the subareas built by areapart. Alternatively,
it can be the output of areapart, a |
win |
Optional, the observation area given as a |
rescale |
Logical. Default to |
plotout |
Logical. Default to |
Details
Batty's spatial entropy measures the heterogeneity in the spatial distribution of a phenomenon of interest, with regard to an area partition. It is high when the phenomenon is equally intense over the sub-areas, and low when it concentrates in one or few sub-areas. This function allows to compute Batty's entropy as
H_B=\sum p_g \log(T_g/p_g)
where p_g
is the probability of occurrence of the phenomenon over sub-area g
,
and T_g
is the sub-area size.
When data are categorical, the phenomenon of interest corresponds to
one category, which must be specified. If data are an unmarked
point pattern, a fake mark vector is be created with the same category for all points.
For comparison purposes, the relative version of Batty's entropy is also returned, i.e.
Batty's entropy divided by its maximum \log(\sum T_g)
.
Note that when the total observation area is 1, then \log(\sum T_g)=0
, therefore
in that case during the computation all T_g
s are multiplied by 100 and a warning is produced.
The function is able to work with grids containing missing data, specified as NA values.
All NAs are ignored in the computation.
Value
A list of five elements:
-
batty
Batty's entropy -
range
The theoretical range of Batty's entropy -
rel.batty
Batty's entropy divided by\log(\sum Tg)
for comparison across observation areas. -
areas
a dataframe giving, for each sub-area of the partition, the absolute and relative frequency of the points/pixels of interest, the sub-area size and the intensity defined aspg/Tg
-
area.tess
atess
object with the area partition
Moreover, a plot is produced showing the data and the area partition.
Examples
#LATTICE DATA
data=matrix((sample(c("a","b","c"), 100, replace=TRUE)), nrow=10)
batty.entropy=batty(data, category="a")
#POINT DATA
#unmarked pp
data=ppp(x=runif(100, 0, 10), y=runif(100, 0, 10), window=square(10))
batty.entropy=batty(data)
#smaller window so that some areas' size are smaller than 1
data=ppp(x=runif(100, 0, 3), y=runif(100, 0, 3), window=square(3))
batty.entropy=batty(data)
#marked pp
data=ppp(x=runif(100, 0, 10), y=runif(100, 0, 10), window=square(10),
marks=(sample(1:5, 100, replace=TRUE)))
plot(data) #see ?plot.ppp for options
#if you want to compute the entropy on all points
batty.entropy=batty(unmark(data))
#if you want to compute the entropy on a category, say 3
batty.entropy=batty(data, category=3)