left_join_raster: Function for extracting values from a raster object based on...

View source: R/left_join_raster.R

left_join_rasterR Documentation

Function for extracting values from a raster object based on points contained within a data frame.

Description

left_join_raster tests if a point is within a raster object and returns the raster's object value if TRUE. This process is analogous to a SQL left join but with a raster object. In raster applications, this is also called an extraction or location process.

Usage

left_join_raster(
  df,
  latitude = "latitude",
  longitude = "longitude",
  projection = "+proj=longlat +datum=WGS84 +no_defs",
  raster,
  name = "raster_value"
)

Arguments

df

Data frame containing latitude and longitude (or other coordinate pair) variables.

latitude

df's latitude variable name.

longitude

df's longitude variable name.

projection

df's latitude and longitude projection system. Default is WGS84.

raster

A raster object to be joined to df.

name

The name of df's new variable sourced from raster. Default is "raster_value".

Details

Points to be tested are generally stored in a data frame with latitude and longitude pairs (or any other projection system) and the raster object must have the same projection system. The result is the input data frame, with the joined raster values. Observations which do not match are filled with NA.

Currently only one layer is used with no buffer. No interpolation or aggregation functions are used either.

raster::extract is used for the join.

Author(s)

Stuart K. Grange

Examples

## Not run: 
# Get ozone concentrations from a raster object
data_select <- left_join_raster(data_select, raster = raster_ozone, 
                                name = "ozone")


## End(Not run)


skgrange/gissr documentation built on Feb. 24, 2024, 2:55 p.m.