R/monitor_writeCurrentStatusGeoJSON.R
monitor_writeCurrentStatusGeoJSON.Rd
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() )
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 |
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
|
propertyNames | Optional character vector supplying custom names for
properties in geoJSON. If NULL or different length than |
metadataList | List of top-level foreign members to include. May include
nested lists as long as they can be converted into JSON using
|
Invisibly returns geoJSON string.
# \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# }