View source: R/airzone_metric.R
assign_airzone | R Documentation |
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).
assign_airzone(
data,
airzones,
az = "Airzone",
station_id = "ems_id",
coords = c("lon", "lat")
)
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' |
For British Columbia, consider using the airzones()
function to
get an sf object of BC airzones from the bcmaps package.
## Not run:
# Using the airzones function from the bcmaps package
bc_airzones <- bcmaps::airzones()
by_airzones <- assign_airzone(data, bc_airzones)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.