Description Usage Arguments Details Value Examples
View source: R/extract_values.R
Extract values of indicators
1 | extract_values(data, allreefs, max.radius = 5000)
|
data |
Dataframe containing the coordinates of the points to extract values for. It must be a four-column dataframe. The 1st and 2nd columns are ignored by the function; they can contain the region name and the site name, for example. Longitude must be on the 3rd column and latitude on the 4th column. |
allreefs |
Object of type sp::SpatialPolygonsDataFrame or sf::sf containing polygons for all reefs with values for all indicators. |
max.radius |
Maximum radius (in meters) to search for nearest polygons. See details. |
The function will first transform the input coordinates into the same coordinate reference system of the allreefs
object,
which follows a WGS84 Pacific-centered reference system (EPSG code: 3832). For each input point, it will then search for the nearest centroid of the polygons of allreefs
and assign it the values of the indicators. The search for the nearest centroid is performed over a circle of radius max.radius
, expressed in meters.
The default value for max.radius
, 5000 meters, reflects the size of the polygons of allreefs (0.05 degrees, which is approximately 5 km).
If no reef polygon centroid is found within a circle of radius max.radius
centered on the input point, the funciton will return NA for that input point.
Increasing max.radius
can extend the search to reef polygons located farther away.
A dataframe. The first four columns are the same as in data
, and the following columns contain the values of the indicators
1 2 3 4 5 6 7 8 9 10 11 | # Create dataframe of sampling points
data <- data.frame(
country = NA,
name = NA,
lon = c(47.7, 48, 48.2),
lat = c(-13.9, -13.5, -13.3)
)
# Load allreefs data
data(allreefs)
# Extract the values of the indicators
extract_values(data, allreefs)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.