knitr::opts_chunk$set(echo = TRUE)
# crayon needs to be explicitly activated in Rmd options(crayon.enabled = TRUE) # Hooks needs to be set to deal with outputs # thanks to fansi logic old_hooks <- fansi::set_knit_hooks(knitr::knit_hooks, which = c("output", "message", "error"))
BOM maintains a shapefile of forecast marine zone names and their geographic locations.
For ease, we'll just use the .dbf file part of the shapefile to extract AAC codes that can be used to add locations to the forecast data.table
that get_coastal_forecast()
returns.
The file is available from BOM's anonymous FTP server with spatial data ftp://ftp.bom.gov.au/anon/home/adfd/spatial/, specifically the DBF file portion of a shapefile, ftp://ftp.bom.gov.au/anon/home/adfd/spatial/IDM00003.dbf.
curl::curl_download( "ftp://ftp.bom.gov.au/anon/home/adfd/spatial/IDM00003.dbf", destfile = paste0(tempdir(), "marine_AAC_codes.dbf"), mode = "wb", quiet = TRUE ) new_marine_AAC_codes <- foreign::read.dbf(paste0(tempdir(), "marine_AAC_codes.dbf"), as.is = TRUE) # convert names to lower case for consistency with bomrang output names(new_marine_AAC_codes) <- tolower(names(new_marine_AAC_codes)) # reorder columns new_marine_AAC_codes <- new_marine_AAC_codes[, c(1, 3, 4, 5, 6, 7)] data.table::setDT(new_marine_AAC_codes) data.table::setkey(new_marine_AAC_codes, "aac")
To ensure that the data being compared is from the most recent release, reinstall bomrang from CRAN.
install.packages("bomrang", repos = "http://cran.us.r-project.org") load(system.file("extdata", "marine_AAC_codes.rda", package = "bomrang")) ( marine_AAC_code_changes <- diffobj::diffPrint(new_marine_AAC_codes, marine_AAC_codes) )
Save the marine zones' metadata and changes to disk for use in bomrang.
if (!dir.exists("../inst/extdata")) { dir.create("../inst/extdata", recursive = TRUE) } marine_AAC_codes <- new_marine_AAC_codes save(marine_AAC_codes, file = "../inst/extdata/marine_AAC_codes.rda", compress = "bzip2") save(marine_AAC_code_changes, file = "../inst/extdata/marine_AAC_code_changes.rda", compress = "bzip2")
sessioninfo::session_info()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.