This function returns the distances (meters) between monitor locations and a location of interest. These distances can be used to create a mask identifying monitors within a certain radius of the location of interest.

monitor_getDistance(
  monitor = NULL,
  longitude = NULL,
  latitude = NULL,
  measure = c("geodesic", "haversine", "vincenty", "cheap")
)

Arguments

monitor

mts_monitor object.

longitude

Longitude of the location of interest.

latitude

Latitude of the location of interest.

measure

One of "geodesic", "haversine" "vincenty", or "cheap".

Value

Named vector of distances (meters) with each distance identified by deviceDeploymentID.

Note

The measure "cheap" may be used to speed things up depending on the spatial scale being considered. Distances calculated with measure = "cheap" will vary by a few meters compared with those calculated using measure = "geodesic".

Examples

library(AirMonitor)

# Walla Walla
longitude <- -118.3302
latitude <- 46.065

distance <- monitor_getDistance(NW_Megafires, longitude, latitude)
closestIndex <- which(distance == min(distance))

# Distance in meters
distance[closestIndex]
#> 197dc3c0d27e2bd5_530710005_04 
#>                      1783.835 

# Monitor core metadata
str(NW_Megafires$meta[closestIndex, AirMonitor::coreMetadataNames])
#> tibble [1 × 27] (S3: tbl_df/tbl/data.frame)
#>  $ deviceDeploymentID   : chr "197dc3c0d27e2bd5_530710005_04"
#>  $ deviceID             : chr "530710005_04"
#>  $ deviceType           : chr NA
#>  $ deviceDescription    : chr "Correlated Radiance Research M903 With Heated Inlet - Nephelometry"
#>  $ deviceExtra          : chr NA
#>  $ pollutant            : chr "PM2.5"
#>  $ units                : chr "UG/M3"
#>  $ dataIngestSource     : chr "EPA AQS"
#>  $ dataIngestURL        : chr "https://aqs.epa.gov/aqsweb/airdata/download_files.html"
#>  $ dataIngestUnitID     : chr NA
#>  $ dataIngestExtra      : chr NA
#>  $ dataIngestDescription: chr NA
#>  $ locationID           : chr "197dc3c0d27e2bd5"
#>  $ locationName         : chr "Walla Wall - 12th St"
#>  $ longitude            : num -118
#>  $ latitude             : num 46.1
#>  $ elevation            : num 267
#>  $ countryCode          : chr "US"
#>  $ stateCode            : chr "WA"
#>  $ countyName           : chr "Walla Walla"
#>  $ timezone             : chr "America/Los_Angeles"
#>  $ houseNumber          : chr NA
#>  $ street               : chr NA
#>  $ city                 : chr NA
#>  $ zip                  : chr NA
#>  $ AQSID                : chr "530710005"
#>  $ fullAQSID            : chr NA