| 1 |
\name{over-methods} |
| 2 |
\docType{methods} |
| 3 |
\alias{over} |
| 4 |
\alias{\%over\%} |
| 5 |
\alias{over-methods} |
| 6 |
\alias{over,SpatialPoints,SpatialPoints-method} |
| 7 |
\alias{over,SpatialPoints,SpatialPointsDataFrame-method} |
| 8 |
\alias{over,SpatialPoints,SpatialPolygons-method} |
| 9 |
\alias{over,SpatialPoints,SpatialPolygonsDataFrame-method} |
| 10 |
\alias{over,SpatialGridDataFrame,SpatialPolygonsDataFrame-method} |
| 11 |
\alias{over,SpatialPolygons,SpatialPoints-method} |
| 12 |
\alias{over,SpatialPolygons,SpatialPointsDataFrame-method} |
| 13 |
\alias{over,SpatialGridDataFrame,SpatialPoints-method} |
| 14 |
\alias{over,SpatialGrid,SpatialPoints-method} |
| 15 |
\alias{over,SpatialPixelsDataFrame,SpatialPoints-method} |
| 16 |
\alias{over,SpatialPixels,SpatialPoints-method} |
| 17 |
\alias{over,SpatialPoints,SpatialGrid-method} |
| 18 |
\alias{over,SpatialPoints,SpatialGridDataFrame-method} |
| 19 |
\alias{over,SpatialPoints,SpatialPixels-method} |
| 20 |
\alias{over,SpatialPoints,SpatialPixelsDataFrame-method} |
| 21 |
\alias{over,SpatialPolygons,SpatialGridDataFrame-method} |
| 22 |
\alias{over,SpatialGrid,SpatialPolygons-method} |
| 23 |
\alias{over,SpatialGrid,SpatialPolygonsDataFrame-method} |
| 24 |
\alias{over,SpatialPolygons,SpatialGrid-method} |
| 25 |
\alias{over,SpatialGrid,SpatialGrid-method} |
| 26 |
\alias{over,SpatialGrid,SpatialGridDataFrame-method} |
| 27 |
\alias{over,SpatialGrid,SpatialPixels-method} |
| 28 |
\alias{over,SpatialGrid,SpatialPixelsDataFrame-method} |
| 29 |
\alias{over,SpatialGrid,SpatialPointsDataFrame-method} |
| 30 |
\alias{over,Spatial,Spatial-method} |
| 31 |
\alias{overDF_for_rgeos} |
| 32 |
|
| 33 |
\title{ consistent spatial overlay for points, grids and polygons } |
| 34 |
\description{ consistent spatial overlay for points, grids and |
| 35 |
polygons: at the spatial locations of object x retrieves the indexes |
| 36 |
or attributes from spatial object y } |
| 37 |
\usage{ |
| 38 |
over(x, y, returnList = FALSE, fn = NULL, ...) |
| 39 |
x \%over\% y |
| 40 |
} |
| 41 |
\arguments{ |
| 42 |
\item{x}{geometry (locations) of the queries} |
| 43 |
\item{y}{layer from which the geometries or attributes are queried} |
| 44 |
\item{returnList}{ logical; see value } |
| 45 |
\item{fn}{(optional) a function; see value } |
| 46 |
\item{...}{arguments passed on to function \code{fn}, except for the special |
| 47 |
argument \code{minDimension}: minimal dimension for an intersection to be counted; |
| 48 |
-1 takes any intersection, and does not order; 0 takes any intersection |
| 49 |
but will order according to dimensionality of the intersections (if returnList |
| 50 |
is TRUE, 1 (2) selects intersections with dimension 1, meaning |
| 51 |
lines (2, meaning areas); see \code{vignette("over")} for details } |
| 52 |
} |
| 53 |
\value{ |
| 54 |
If \code{y} is only geometry an object of length \code{length(x)}. |
| 55 |
If \code{returnList} is \code{FALSE}, a vector with the (first) index |
| 56 |
of \code{y} for each geometry (point, grid cell centre, polygon |
| 57 |
or lines) matching \code{x}. if \code{returnList} is TRUE, a list of |
| 58 |
length \code{length(x)}, with list element \code{i} the vector of |
| 59 |
all indices of the geometries in \code{y} that correspond to the |
| 60 |
$i$-th geometry in \code{x}. |
| 61 |
|
| 62 |
If \code{y} has attribute data, attribute data are |
| 63 |
returned. \code{returnList} is FALSE, a \code{data.frame} with |
| 64 |
number of rows equal to \code{length(x)} is returned, if it is |
| 65 |
TRUE a list with \code{length(x)} elements is returned, with a list |
| 66 |
element the \code{data.frame} elements of all geometries in \code{y} |
| 67 |
that correspond to that element of \code{x}. |
| 68 |
|
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
\section{Methods}{ |
| 73 |
\describe{ |
| 74 |
\item{x = "SpatialPoints", y = "SpatialPolygons"}{ returns a numeric |
| 75 |
vector of length equal to the number of points; the number is the |
| 76 |
index (number) of the polygon of \code{y} in which a point falls; |
| 77 |
NA denotes the point does not fall in a polygon; if a point falls |
| 78 |
in multiple polygons, the last polygon is recorded. } |
| 79 |
\item{x = "SpatialPointsDataFrame", y = "SpatialPolygons"}{ equal |
| 80 |
to the previous method, except that an argument \code{fn=xxx} is |
| 81 |
allowed, e.g. \code{fn = mean} which will then report a data.frame |
| 82 |
with the mean attribute values of the \code{x} points falling |
| 83 |
in each polygon (set) of \code{y} } |
| 84 |
\item{x = "SpatialPoints", y = "SpatialPolygonsDataFrame"}{ returns |
| 85 |
a data.frame of the second argument with row entries corresponding |
| 86 |
to the first argument } |
| 87 |
\item{x = "SpatialPolygons", y = "SpatialPoints"}{ returns |
| 88 |
the polygon index of points in \code{y}; if \code{x} is |
| 89 |
a \code{SpatialPolygonsDataFrame}, a data.frame with rows from |
| 90 |
\code{x} corresponding to points in \code{y} is returned.} |
| 91 |
\item{x = "SpatialGridDataFrame", y = "SpatialPoints"}{ returns |
| 92 |
object of class SpatialPointsDataFrame with grid attribute values |
| 93 |
x at spatial point locations y; NA for NA grid cells or points |
| 94 |
outside grid, and NA values on NA grid cells. } |
| 95 |
\item{x = "SpatialGrid", y = "SpatialPoints"}{ returns grid values |
| 96 |
x at spatial point locations y; NA for NA grid cells or points |
| 97 |
outside the grid } |
| 98 |
\item{x = "SpatialPixelsDataFrame", y = "SpatialPoints"}{ returns |
| 99 |
grid values x at spatial point locations y; NA for NA grid cells |
| 100 |
or points outside the grid } |
| 101 |
\item{x = "SpatialPixels", y = "SpatialPoints"}{ returns grid |
| 102 |
values x at spatial point locations y; NA for NA grid cells or |
| 103 |
points outside the grid } |
| 104 |
\item{x = "SpatialPoints", y = "SpatialGrid"}{ xx } |
| 105 |
\item{x = "SpatialPoints", y = "SpatialGridDataFrame"}{ xx } |
| 106 |
\item{x = "SpatialPoints", y = "SpatialPixels"}{ xx } |
| 107 |
\item{x = "SpatialPoints", y = "SpatialPixelsDataFrame"}{ xx } |
| 108 |
\item{x = "SpatialPolygons", y = "SpatialGridDataFrame"}{ xx } |
| 109 |
} |
| 110 |
} |
| 111 |
\author{Edzer Pebesma, \email{[email protected]}} |
| 112 |
|
| 113 |
\note{\code{over} can be seen as a left outer join in SQL; the |
| 114 |
match is a spatial intersection. |
| 115 |
|
| 116 |
points on a polygon boundary and points corresponding to a |
| 117 |
polygon vertex are considered to be inside the polygon. |
| 118 |
|
| 119 |
These methods assume that pixels and grid cells are never |
| 120 |
overlapping; for objects of class \code{SpatialPixels} this is |
| 121 |
not guaranteed. |
| 122 |
|
| 123 |
} |
| 124 |
|
| 125 |
\seealso{ |
| 126 |
\code{vignette("over")} for examples and figures} |
| 127 |
\keyword{methods} |