From 3a29c5efe2b7ec715519e378718706bfa2ae7b43 Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sat, 7 Dec 2024 22:09:34 +0800 Subject: [PATCH 1/2] add new function to print netcdf file format info in console for AGFD --- NAMESPACE | 1 + R/get_agfd.R | 34 ++++++++++++++++++++++++++++++++++ codemeta.json | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index f4916ec..e1fa63d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,6 +22,7 @@ export(get_historical_state_estimates) export(get_soil_thickness) export(inspect_cache) export(plot) +export(print_agfd_nc_file_format) export(print_soil_thickness_metadata) export(read_agfd_dt) export(read_agfd_stars) diff --git a/R/get_agfd.R b/R/get_agfd.R index a70462f..9072ca8 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -242,3 +242,37 @@ print.read.abares.agfd.nc.files <- function(x, ...) { cli::cat_line() invisible(x) } + +#' Prints File Format Information for the AGFD NetCDF Files +#' +#' Print the file format from section 3.2 in \cite{Australian Bureau of +#' Agricultural and Resource Economics and Sciences}. +#' +#' @references Australian gridded farm data, Australian Bureau of Agricultural +#' and Resource Economics and Sciences, Canberra, July, DOI: +#' +#' @source +#' @examples +#' print_agfd_nc_file_format() +#' +#' @export +#' @autoglobal +#' @noRd +print_agfd_nc_file_format <- function() { + cli::cat_rule() + cli::cli_text("Each of the layers in simulation output data is represented as + a 2D raster in NETCDF files, with the following grid format:") + cli::cat_line() + cli::cli_dl( + c( + "{.strong CRS}" = "EPSG:4326 - WGS 84 – Geographic", + "{.strong Extent}" = "111.975 -44.525 156.275 -9.975", + "{.strong Unit}" = "Degrees", + "{.strong Width}" = "886", + "{.strong Height}" = "691", + "{.strong Cell size}" = "0.05 degree x 0.05 degree" + ) + ) + cli::cat_rule() +} + diff --git a/codemeta.json b/codemeta.json index 2c67ebf..389d41a 100644 --- a/codemeta.json +++ b/codemeta.json @@ -333,7 +333,7 @@ }, "SystemRequirements": null }, - "fileSize": "387.526KB", + "fileSize": "388.674KB", "citation": [ { "@type": "SoftwareSourceCode", From a2fbfcc198cc887d03e5fe422e0c4893d36f73db Mon Sep 17 00:00:00 2001 From: "Adam H. Sparks" Date: Sat, 7 Dec 2024 23:45:05 +0800 Subject: [PATCH 2/2] add function to display AGFD file data format info and document it --- R/get_agfd.R | 2 ++ codemeta.json | 2 +- vignettes/read.abares.Rmd | 21 ++++++++++++++++++++- vignettes/read.abares.Rmd.orig | 6 ++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/R/get_agfd.R b/R/get_agfd.R index 9072ca8..a95bc43 100644 --- a/R/get_agfd.R +++ b/R/get_agfd.R @@ -274,5 +274,7 @@ print_agfd_nc_file_format <- function() { ) ) cli::cat_rule() + cli::cli_text("For further details, see the ABARES website, + {.url https://www.agriculture.gov.au/abares/research-topics/surveys/farm-survey-data/australian-gridded-farm-data}") } diff --git a/codemeta.json b/codemeta.json index 389d41a..72dfdb2 100644 --- a/codemeta.json +++ b/codemeta.json @@ -333,7 +333,7 @@ }, "SystemRequirements": null }, - "fileSize": "388.674KB", + "fileSize": "390.077KB", "citation": [ { "@type": "SoftwareSourceCode", diff --git a/vignettes/read.abares.Rmd b/vignettes/read.abares.Rmd index dfa732e..70befc2 100644 --- a/vignettes/read.abares.Rmd +++ b/vignettes/read.abares.Rmd @@ -42,6 +42,25 @@ Load the {read.abares} library. library(read.abares) ``` +Check the file format information for the NetCDF files. + + +``` r +print_agfd_nc_file_format() +#> ──────────────────────────────────────────────────────────────────────────────────────── +#> Each of the layers in simulation output data is represented as a 2D raster in NETCDF +#> files, with the following grid format: +#> CRS: EPSG:4326 - WGS 84 – Geographic +#> Extent: 111.975 -44.525 156.275 -9.975 +#> Unit: Degrees +#> Width: 886 +#> Height: 691 +#> Cell size: 0.05 degree x 0.05 degree +#> ──────────────────────────────────────────────────────────────────────────────────────── +#> For further details, see the ABARES website, +#> +``` + Download or load from the local cache and read the AGFD files as a list of {stars} objects. @@ -110,7 +129,7 @@ head(tdnc[[1]]) #> # A tibble: 1 × 2 #> access source #> -#> 1 2024-12-07 21:23:36 /Users/adamsparks/Library/Caches/org.R-project.R/R/read.abares/hi… +#> 1 2024-12-07 23:43:59 /Users/adamsparks/Library/Caches/org.R-project.R/R/read.abares/hi… #> #> $axis #> # A tibble: 84 × 3 diff --git a/vignettes/read.abares.Rmd.orig b/vignettes/read.abares.Rmd.orig index 2b28dc1..e569c0d 100644 --- a/vignettes/read.abares.Rmd.orig +++ b/vignettes/read.abares.Rmd.orig @@ -46,6 +46,12 @@ Load the {read.abares} library. library(read.abares) ``` +Check the file format information for the NetCDF files. + +```{r agfd-file-format} +print_agfd_nc_file_format() +``` + Download or load from the local cache and read the AGFD files as a list of {stars} objects. ```{r agfd-stars}