assign_airzone: Assign locations to airzones

View source: R/airzone_metric.R

assign_airzoneR Documentation

Assign locations to airzones

Description

With a data set containing station locations, calculate which airzones each station belongs to. Requires an sf object from the sf package containing the airzone names and locations (polygons).

Usage

assign_airzone(
  data,
  airzones,
  az = "Airzone",
  station_id = "ems_id",
  coords = c("lon", "lat")
)

Arguments

data

Data frame. Contains station ids and air quality data

airzones

sf PPOLYGON or MULTIPOLYGON reflecting airzone locations

az

Character. Name of airzones column in the 'airzones' sf object

station_id

Character. Name of the station_id column in 'data'

coords

Character vector. Names of the columns containing longitude and latitude (respectively) for each station. Defaults to 'lon' and 'lat'

Details

For British Columbia, consider using the airzones() function to get an sf object of BC airzones from the bcmaps package.

Examples


## Not run: 
# Using the airzones function from the bcmaps package
bc_airzones <- bcmaps::airzones()

by_airzones <- assign_airzone(data, bc_airzones)

## End(Not run)


bcgov/rcaaqs documentation built on Dec. 12, 2023, 9:21 a.m.