huff: Huff Catchment Areas

View source: R/huff.R

huffR Documentation

Huff Catchment Areas

Description

This function computes the catchment areas as defined by D. Huff (1964).

Usage

huff(
  knownpts,
  unknownpts,
  matdist,
  varname,
  typefct = "exponential",
  span,
  beta,
  resolution,
  mask,
  bypassctrl = FALSE,
  longlat = TRUE,
  returnclass = "sp"
)

Arguments

knownpts

sp or sf object; this is the set of known observations to estimate the catchment areas from.

unknownpts

sp or sf object; this is the set of unknown units for which the function computes the estimates. Not used when resolution is set up. (optional)

matdist

matrix; distance matrix between known observations and unknown units for which the function computes the estimates. Row names match the row names of knownpts and column names match the row names of unknownpts. matdist can contain any distance metric (time distance or euclidean distance for example). If matdist is not set, the distance matrix is automaticly built with CreateDistMatrix. (optional)

varname

character; name of the variable in the knownpts dataframe from which values are computed. Quantitative variable with no negative values.

typefct

character; spatial interaction function. Options are "pareto" (means power law) or "exponential". If "pareto" the interaction is defined as: (1 + alpha * mDistance) ^ (-beta). If "exponential" the interaction is defined as: exp(- alpha * mDistance ^ beta). The alpha parameter is computed from parameters given by the user (beta and span).

span

numeric; distance where the density of probability of the spatial interaction function equals 0.5.

beta

numeric; impedance factor for the spatial interaction function.

resolution

numeric; resolution of the output grid (in map units). If resolution is not set, the grid will contain around 7000 points. (optional)

mask

sp or sf object; the spatial extent of this object is used to create the regularly spaced points output. (optional)

bypassctrl

logical; bypass the distance matrix size control (see CreateDistMatrix Details).

longlat

logical; if FALSE, Euclidean distance, if TRUE Great Circle (WGS84 ellipsoid) distance.

returnclass

"sp" or "sf"; class of the returned object.

Value

Point object with the computed catchment areas in a new field named OUTPUT.

References

HUFF D. (1964) Defining and Estimating a Trading Area. Journal of Marketing, 28: 34-38.

See Also

huff, rasterHuff, plotHuff, CreateGrid, CreateDistMatrix.

Examples

# Create a grid of paris extent and 200 meters
# resolution
data(hospital)
mygrid <- CreateGrid(w = paris, resolution = 200, returnclass = "sf")
# Create a distance matrix between known points (hospital) and mygrid
mymat <- CreateDistMatrix(knownpts = hospital, unknownpts = mygrid, 
                          longlat = FALSE)
# Compute Huff catchment areas from known points (hospital) on a given
# grid (mygrid) using a given distance matrix (mymat)
myhuff <- huff(knownpts = hospital, unknownpts = mygrid,
               matdist = mymat, varname = "capacity",
               typefct = "exponential", span = 1250,
               beta = 3, mask = paris, returnclass = "sf")
# Compute Huff catchment areas from known points (hospital) on a
# grid defined by its resolution
myhuff2 <- huff(knownpts = hospital, varname = "capacity",
                typefct = "exponential", span = 1250, beta = 3,
                resolution = 200, mask = paris, returnclass= "sf")
# The two methods have the same result
identical(myhuff, myhuff2)
# the function output an sf object
class(myhuff)

SpatialPosition documentation built on Sept. 14, 2023, 5:07 p.m.