getSpatialData: Return spatial data associated with a set of locations

View source: R/getSpatialData.R

getSpatialDataR Documentation

Return spatial data associated with a set of locations

Description

All locations are first converted to SpatialPoints objects. The st_intersects function is then used to determine which polygon from SFDF each location falls in. The dataframe row associated with each polygon is then associated with each location.

Usage

getSpatialData(
  longitude = NULL,
  latitude = NULL,
  SFDF = NULL,
  useBuffering = FALSE,
  verbose = FALSE
)

Arguments

longitude

Vector of longitudes in decimal degrees East.

latitude

Vector of latitudes in decimal degrees North.

SFDF

sf dataframe with MULTIPOLYGON geometry.

useBuffering

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

verbose

Logical flag controlling detailed progress statements.

Details

For coastal locations, locations may lie just outside the boundaries of an individual polygon, especially if it is of low resolution. To account for this any location that remains unassociated after the first pass is checked to seee if it is with a specific distance of any polygon. The set of distances is gradually increased until a polygon is reached or the maximum distances is encountered. Distances include: 1km, 2km, 5km, 10km, 20km, 50km, 100km, 200km. If a location is more than 200km away from any polygon, a data frame record with all NAs is returned for that location.

Missing or invalid values in the incoming longitude or latitude vectors result in records with all NAs at those positions in the returned data frame.

Value

Dataframe of data.


MazamaScience/MazamaSpatialUtils documentation built on Sept. 14, 2023, 6 p.m.