kde2d.G {GRASS} | R Documentation |
A version of kde2d()
in the MASS package of the VR collection using the metadata of the underlying GRASS LOCATION. kde2d()
is for "two-dimensional kernel density estimation with an axis-aligned bivariate normal kernel, evaluated on a square grid." An optional feature is the introduction of a weighted moving average through the Z argument.
kde2d.G(G, x, y, h, reverse=NULL, Z=NULL)
G |
GRASS metadata from gmeta() |
x |
x coordinate of data |
y |
y coordinate of data |
h |
vector of bandwidths for x and y directions. Defaults to normal reference bandwidth. |
reverse |
see help(reverse) |
Z |
vector of attribute values |
A vector of G$Ncells
values is returned, with the results of density/weighted moving average calculations ordered as a GRASS raster file. Density values are points per unit area, while moving average values are in the units of the Z variable.
The functions in this package are intended to work with the GRASS geographical information system. The examples for wrapper functions will will work whether or not R is running in GRASS, and whether or not the current location is that of the data set used for the examples. Examples of interface functions will however (from version 0.2-2) only work outside GRASS, to avoid possible overwriting of GRASS database locations and/or files.
Original kde2d(), bandwidth.nrd()
: Brian D. Ripley and Bill Venables as detailed in the MASS package documentation; adapted by Roger S. Bivand, e-mail: Roger.Bivand@nhh.no.
http://grass.itc.it/statsgrass/index.html, Bivand, R. S., (2000) Using the R statistical data analysis language on GRASS 5.0 GIS data base files. Computers and Geosciences, 26, pp. 1043-1052.
data(utm.maas) G <- maas.metadata inregion <- (utm.maas$east >= G$w & utm.maas$east <= G$e) & (utm.maas$north >= G$s & utm.maas$north <= G$n) if(all(!inregion)) stop("None of the site locations are inside the current GRASS region") if(any(!inregion)) warning("Some site locations are outside the current GRASS region") plot(G, kde2d.G(G=G, utm.maas$east, utm.maas$north, h=c(300,300))*maasmask) points(utm.maas$east, utm.maas$north) rug(utm.maas$east, side=1, ticksize=0.02) rug(utm.maas$north, side=2, ticksize=0.02) title(main="Kernel estimates of density of soil sample placing", xlab="(Bailey & Gatrell, pp. 84-88") plot(G, kde2d.G(G=G, utm.maas$east, utm.maas$north, h=c(300,300), Z=utm.maas$Zn)*maasmask) points(utm.maas$east, utm.maas$north) rug(utm.maas$east, side=1, ticksize=0.02) rug(utm.maas$north, side=2, ticksize=0.02) title(main="Kernel density weighted average, Zn ppm", xlab="(Bailey & Gatrell, pp. 159-161")