getSpatialData: Return spatial data associated with a set of locations

Description Usage Arguments Details Value

View source: R/getSpatialData.R

Description

All locations are first converted to SpatialPoints objects. The sp::over() function is then used to determine which polygon from SPDF each location falls in. The dataframe row associated with each polygon is then associated with each location.

Usage

1
getSpatialData(lon, lat, SPDF, useBuffering = FALSE, verbose = FALSE)

Arguments

lon

Vector of longitudes in decimal degrees.

lat

Vector of latitudes in decimal degrees.

SPDF

Object of class SpatialPolygonsDataFrame.

useBuffering

Logical flag specifying the use of location buffering to find the nearest polygon if not target polygon is found.

verbose

Logical flag controlling detailed progress statements.

Details

Occasionally for coastal locations the precise coordinates lie outside the boundaries of a low resolution SpatialPolygonsDataFrame. To account for this any location that remains unassociated after the first pass is then buffered to create a small circle around the original location. All polygons are then checked to see if there is any intersection with the now larger buffered locations. Each point is then checked for an intersecting polygon at the following radii: 1km, 2km, 5km, 10km, 20km, 50km, 100km, 200km. If a buffered location is more than 200km away from any polygon, a value of NA (or data frame row with all NAs) is returned for that location.

Missing or invalid values in the incoming lon or lat vectors result in NAs at those positions in the returned vector or data frame.

Value

Vector or dataframe of data.


MazamaSpatialUtils documentation built on Sept. 29, 2019, 1:03 a.m.