Description Usage Arguments Value Author(s) Examples
This function uses the nn2() function from the RANN package to come up with a shorter list of candidates on which point.in.polygon() from the sp package can be applied.
1 2 | SearchForPolygon(poly.list, XY, k, poly.id, poly.id.colname,
verbose = 0)
|
poly.list |
polygon list with 3-4 elements: poly.centers, data, polys and possibly ranges |
XY |
data frame containing X-Y columns to assign polygons to |
k |
maximum number of nearest neighbours to compute. The default value is set to 10. |
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 |
Returns data frame with identified polygon and nearest neighbour rank
Markus Loecher <markus.loecher@gmail.com> and Madhav Kumar <madhavkumar2005@gmail.com>
1 2 3 4 5 | data(sf.crime.2012, envir = environment())
data(sf.polys, envir = environment())
XY.polys <- SearchForPolygon(poly.list= sf.polys, XY= sf.crime.2012[1:1000,], k= 10,
poly.id= "fips", poly.id.colname= "census.block",
verbose= TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.