Last data update: 2014.03.03

R: Use range-search to map points to polygon.
FindPolygonInRangesR Documentation

Use range-search to map points to polygon.

Description

This function searches the lat-long ranges of polygons to come up with a shorter list of candidates on which point.in.polygon() from the sp package can be applied.

Usage

FindPolygonInRanges(poly.list, XY, poly.id = "fips", poly.id.colname = "census.block", 
    verbose = 0)

Arguments

poly.list

polygon list with 3 or 4 elements: data, polys, poly.centers, and possibly ranges

XY

data frame containing X-Y columns

poly.id

column name in 'poly.list$data' containing the polygon identifier

poly.id.colname

desired column name in the output data frame containing the polygon identifier

verbose

level of verbosity

Author(s)

Markus Loecher <markus.loecher@gmail.com> and Madhav Kumar <madhavkumar2005@gmail.com>

Examples


data(sf.crime.2012, envir = environment())
data(sf.polys, envir = environment())

sf.polys <- AddRanges(sf.polys)
XY <- FindPolygonInRanges(sf.polys, sf.crime.2012[1:1000,], verbose=0)

which(is.na(XY[,"census.block"]))
table(XY$rank)

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(RapidPolygonLookup)
Loading required package: sp
Loading required package: RANN
Loading required package: PBSmapping

-----------------------------------------------------------
PBS Mapping 2.69.76 -- Copyright (C) 2003-2016 Fisheries and Oceans Canada

PBS Mapping comes with ABSOLUTELY NO WARRANTY;
for details see the file COPYING.
This is free software, and you are welcome to redistribute
it under certain conditions, as outlined in the above file.

A complete user guide 'PBSmapping-UG.pdf' is located at 
/home/ddbj/local/lib64/R/library/PBSmapping/doc/PBSmapping-UG.pdf

Packaged on 2015-04-23
Pacific Biological Station, Nanaimo

All available PBS packages can be found at
http://code.google.com/p/pbs-software/

To see demos, type '.PBSfigs()'.
-----------------------------------------------------------


Loading required package: RgoogleMaps
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RapidPolygonLookup/FindPolygonInRanges.Rd_%03d_medium.png", width=480, height=480)
> ### Name: FindPolygonInRanges
> ### Title: Use range-search to map points to polygon.
> ### Aliases: FindPolygonInRanges
> 
> ### ** Examples
> 
> 
> data(sf.crime.2012, envir = environment())
> data(sf.polys, envir = environment())
> 
> sf.polys <- AddRanges(sf.polys)
> XY <- FindPolygonInRanges(sf.polys, sf.crime.2012[1:1000,], verbose=0)
> 
> which(is.na(XY[,"census.block"]))
integer(0)
> table(XY$rank)

  1   2   3   4   5 
548 268 132  43   9 
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>