Writes a geoJSON file containing current monitor data. For details on what is included, see monitor_getCurrentStatus.

monitor_writeCurrentStatusGeoJSON(
  ws_monitor,
  filename,
  datetime = lubridate::now(tzone = "UTC"),
  properties = NULL,
  propertyNames = NULL,
  metadataList = list()
)

Arguments

ws_monitor

ws_monitor object.

filename

Filename where geojson file will be saved.

datetime

Time to which data will be 'current' (integer or character representing YYYYMMDDHH or POSIXct. If not POSIXct, interpreted as UTC time). So if datetime is 3 hours ago, a dataframe with the most current data from 3 hours ago will be returned.

properties

Optional character vector of properties to include for each monitor in geoJSON. If NULL all are included. May include any ws_monitor metadata and additional columns generated in monitor_getCurrentStatus.

propertyNames

Optional character vector supplying custom names for properties in geoJSON. If NULL or different length than properties defaults will be used.

metadataList

List of top-level foreign members to include. May include nested lists as long as they can be converted into JSON using jsonlite::toJSON(). For more information on what can be included see https://tools.ietf.org/html/rfc7946#section-6.1.

Value

Invisibly returns geoJSON string.

Examples

# \donttest{ # Fail gracefully if any resources are not available try({ library(PWFSLSmoke) wa <- monitor_loadLatest() %>% monitor_subset(stateCodes = "WA") geojson_file <- tempfile(fileext = ".geojson") wa_current_geojson <- monitor_writeCurrentStatusGeoJSON(wa, geojson_file) wa_current_list <- jsonlite::fromJSON(wa_current_geojson) wa_spdf <- rgdal::readOGR(dsn = geojson_file) map("state", "washington") points(wa_spdf) }, silent = FALSE)
#> Warning: Discarded datum Unknown based on WGS84 ellipsoid in Proj4 definition
#> OGR data source with driver: GeoJSON #> Source: "/private/var/folders/84/y311lppx4519st7n8_gfkd1w0000gn/T/RtmpmbMo3h/file9b463e823a85.geojson", layer: "currentTbl" #> with 70 features #> It has 45 fields
# }