Skip to contents

Index a list of points (e.g., schools) so getpointsnearby() can find them very quickly

Usage

indexpoints(pts, indexname = "custom_index", envir = globalenv())

Arguments

pts

a data.frame or data.table with columns name lat and lon, one row per location (point), and any other columns are ignored.

indexname

optional name to give the index

envir

optional environment - default is to assign index object to globalenv()

Value

Just returns TRUE when done. Side effect is to put into the globalenv() (or specified envir) that spatial index with name defined by indexname, as created by indexpoints().

Details

This creates a spatial index to be used by getpointsnearby() to support proxistat(), to create a new proximity score for every block and block group in the US. It relies on create_quaddata() for one step, then SearchTrees::createTree()

Examples

if (FALSE) { # \dontrun{
  # EXAMPLES NOT TESTED YET ***
  pts <- testpoints_10
  tempenv <- new.env()
  index10 <- indexpoints(pts, "index10", envir = tempenv)
  x <- getpointsnearby(pts, quadtree = get(index10, envir = tempenv))
  # y <- proxistat(pts)
  # rm(custom_index)
 } # }