Learn R Programming

seg (version 0.2-2)

getSegLocalEnv: Calculate Local Environment Parameters

Description

Calculate the population composition of the local environment at each data point from a matrix of coordinates, or an object of class Spatial or ppp.

Usage

getSegLocalEnv(x, data, power = 2, useExp = TRUE, maxdist, 
               sprel, error = .Machine$double.eps)

Arguments

x
a numeric matrix or data frame with coordinates (each row is a point), or an object of class Spatial or ppp.
data
an object of class matrix, or one that can be coerced to that class. The number of rows in data should equal the number of points in x, and the number of columns should be greater than one (at least two popul
power
a numeric value that determines the change rate of a distance weight function. If zero, all data points have the same weight regardless of the distance. Typically 1-5.
useExp
logical. If FALSE, use a simple inverse distance function instead of a negative exponential function. See Details.
maxdist
an optional numeric value specifying a search radius for the construction of each local environment. Must be a positive value, or zero.
sprel
an optional object of class dist or nb. See Details.
error
a numeric value. If useExp = FALSE, this value will be added to the denominator to prevent dividing by zero.

Value

  • An object of class LocalEnv.

Details

The local environment parameters are the weighted averages of the populations of all points within a search radius maxdist and are an essential component for calculation of the spatial segregation measures.

By default, the weight of each point is calculated from a negative exponential function, which is defined as:

$$w(d) = e^{-d \times power}$$

where d is the Euclidean distance between two points.

If useExp is FALSE, a simple inverse distance function is used to calculate the weight of each point:

$$w(d) = \frac{1}{(d + error)^{power}}$$

If maxdist is not provided (default), all data points in the study area are used for the construction of each local environment. It is recommended to specify this parameter to speed up the calculation process.

If a distance measure other than the Euclidean distance is required to represent spatial proximity between the points, the users can provide an object of class dist, which contains the distances between all pairs of the points, through an optional argument sprel. One convenient way of obtaining such information may be the use of the function dist, which offers a variety of distance measures, such as Manhattan, Canberra, and Minkowski.

Or alternatively, one can supply an object of class nb to use a k-nearest neighbour averaging or polygon contiguity.

See Also

SegLocalEnv, SegLocalEnv-class, spseg, dist

Examples

Run this code
# Create a random data set with 50 data points and 3 population groups
xy <- matrix(runif(100), ncol = 2)
pop <- matrix(runif(150), ncol = 3)

env1 <- getSegLocalEnv(xy, pop)
summary(env1)

xy.dist <- dist(xy, method = "manhattan")
maxdist <- quantile(as.matrix(xy), 0.75)
env2 <- getSegLocalEnv(xy, pop, maxdist = maxdist, sprel = xy.dist)
summary(env2)

env3 <- getSegLocalEnv(xy, pop, useExp = FALSE, power = 0, maxdist = 0.5)
summary(env3)

env4 <- getSegLocalEnv(xy, pop, useExp = FALSE, maxdist = 0.5)
summary(env4)

Run the code above in your browser using DataLab