Changes the location associated with an existing time series. This will update the following fields in monitor$meta: longitude, latitude, locationID and deviceDeploymentID as well as the column name of this time series in monitor$data.

monitor_move(
  monitor,
  id = NULL,
  longitude = NULL,
  latitude = NULL,
  algorithm = NULL,
  precision = 10
)

Arguments

monitor

mts_monitor object.

id

deviceDeploymentID for a single time series found in monitor. (Optional if monitor contains only a single time series.)

longitude

New longitude of the time series.

latitude

New latitude of the time series.

algorithm

Algorithm to use – either "geohash" or "digest".

precision

precision argument used when encoding with "geohash".

Value

A mts_monitor object representing a single time series. (A list with meta and data dataframes.)

Details

If another time series exists at the the specified location, monitor_combine() will be used to join them into a single time series. Combination will be performed with replaceMeta = TRUE, overlapStrategy = "replace all" to ensure that data and metadata associated with the later time series take precedence.

A typical use case would involve a monitor whose location metadata was update/corrected after data collection has already started. This will result in two separate time series that need to be combined.

Note

Arguments algorithm and precision are passed on to createLocationID so that the new locationID will match those found in monitor. If algorithm = NULL, the algorithm and precision will be chosen to match those used to create mon$meta$locationID.

Examples

library(AirMonitor)

# Move Carmel Vallely monitor over a bit

names(Carmel_Valley$data)
#> [1] "datetime"                      "a9572a904a4ed46d_840060530002"
Carmel_Valley$meta %>%
  dplyr::select(longitude, latitude, locationID, deviceDeploymentID) %>%
  dplyr::glimpse()
#> Rows: 1
#> Columns: 4
#> $ longitude          <dbl> -121.7333
#> $ latitude           <dbl> 36.48187
#> $ locationID         <chr> "a9572a904a4ed46d"
#> $ deviceDeploymentID <chr> "a9572a904a4ed46d_840060530002"

moved_monitor <- monitor_move(
  Carmel_Valley,
  id = Carmel_Valley$meta$deviceDeploymentID,
  longitude = Carmel_Valley$meta$longitude + 0.001,
  latitude = Carmel_Valley$meta$latitude + 0.001
)

names(moved_monitor$data)
#> [1] "datetime"                      "0d72cd782d6a0dd5_840060530002"
moved_monitor$meta %>%
  dplyr::select(longitude, latitude, locationID, deviceDeploymentID) %>%
  dplyr::glimpse()
#> Rows: 1
#> Columns: 4
#> $ longitude          <dbl> -121.7323
#> $ latitude           <dbl> 36.48287
#> $ locationID         <chr> "0d72cd782d6a0dd5"
#> $ deviceDeploymentID <chr> "0d72cd782d6a0dd5_840060530002"