Given a set of points, a bandwidth, a grid density and a frame, produce a kernel density estimate
Usage
kde.points(pts,h,n=200,lims=NULL)
Arguments
pts
A SpatialPoints or SpatialPointsDataFrame object.
h
A real number - the bandwidth of the KDE
n
An integer, the output grid density - ie result is nxn grid
lims
A spatial object - the KDE grid will cover this, if provided
Value
A SpatialPixelsDataFrame containing the KDE.
Author(s)
Chris Brunsdon
Examples
# Data for New Haven to use in example
data(newhaven)
# Do the KDE
breach.dens = kde.points(breach,lims=tracts)
# Plot the result
level.plot(breach.dens)
# Block out the part outside the study area
masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker)
# Plot census tract boundaries
plot(tracts,add=TRUE)
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(GISTools)
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
Loading required package: RColorBrewer
Loading required package: MASS
Loading required package: rgeos
rgeos version: 0.3-19, (SVN revision 524)
GEOS runtime version: 3.5.0-CAPI-1.9.0 r4084
Linking to sp version: 1.2-3
Polygon checking: TRUE
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GISTools/kde.polys.Rd_%03d_medium.png", width=480, height=480)
> ### Name: Kernel Density Estimates From Points
> ### Title: Kernel Density Estimates
> ### Aliases: kde.points
>
> ### ** Examples
>
> # Data for New Haven to use in example
> data(newhaven)
> # Do the KDE
> breach.dens = kde.points(breach,lims=tracts)
> # Plot the result
> level.plot(breach.dens)
> # Block out the part outside the study area
> masker = poly.outer(breach.dens,tracts,extend=100); add.masking(masker)
> # Plot census tract boundaries
> plot(tracts,add=TRUE)
>
>
>
>
>
> dev.off()
null device
1
>