diff --git a/R/geotargets-option.R b/R/geotargets-option.R index 96f2395..22c0bad 100644 --- a/R/geotargets-option.R +++ b/R/geotargets-option.R @@ -8,14 +8,14 @@ #' #' ## Available Options #' -#' - `"geotargets.raster.gdal_creation_options"` - set the GDAL creation options used when writing raster files to target store (default: `"ENCODING=UTF-8"`) +#' - `"geotargets.gdal.raster.creation_options"` - set the GDAL creation options used when writing raster files to target store (default: `"ENCODING=UTF-8"`) #' -#' - `"geotargets.raster.gdal_driver_name"` - set the file type used for raster data in target store (default: `"GTiff"`) +#' - `"geotargets.gdal.raster.driver_name"` - set the file type used for raster data in target store (default: `"GTiff"`) #' #' Each option can be overridden with a system environment variable. Options include: #' -#' - `GEOTARGETS_RASTER_GDAL_CREATION_OPTIONS` -#' - `GEOTARGETS_RASTER_GDAL_DRIVER_NAME` +#' - `GEOTARGETS_GDAL_RASTER_CREATION_OPTIONS` +#' - `GEOTARGETS_GDAL_RASTER_DRIVER_NAME` #' #' @rdname geotargets-options #' @export @@ -30,27 +30,27 @@ geotargets_option_get <- function(option_name) { getOption(option_name, default = option_value %||% name) } - get_geotargets_raster_gdal_creation_options <- function(option_name, option_value) { + get_geotargets_gdal_raster_creation_options <- function(option_name, option_value) { gdal_creation_options <- Sys.getenv( - x = "GEOTARGETS_RASTER_GDAL_CREATION_OPTIONS", + x = "GEOTARGETS_GDAL_RASTER_CREATION_OPTIONS", unset = get_option(option_name, option_value, "ENCODING=UTF-8") ) the_option <- strsplit(gdal_creation_options, ";")[[1]] the_option } - get_geotargets_raster_gdal_driver_name <- function(option_name, option_value) { + get_geotargets_gdal_raster_driver_name <- function(option_name, option_value) { Sys.getenv( - x = "GEOTARGETS_RASTER_GDAL_DRIVER_NAME", + x = "GEOTARGETS_GDAL_RASTER_DRIVER_NAME", unset = get_option(option_name, option_value, "GTiff") ) } switch(option_name, - "geotargets.raster.gdal_creation_options" = - get_geotargets_raster_gdal_creation_options(option_name, option_value), - "geotargets.raster.gdal_driver_name" = - get_geotargets_raster_gdal_driver_name(option_name, option_value) + "geotargets.gdal.raster.creation_options" = + get_geotargets_gdal_raster_creation_options(option_name, option_value), + "geotargets.gdal.raster.driver_name" = + get_geotargets_gdal_raster_driver_name(option_name, option_value) ) } diff --git a/R/tar-terra-rast.R b/R/tar-terra-rast.R index d5d005b..213c06d 100644 --- a/R/tar-terra-rast.R +++ b/R/tar-terra-rast.R @@ -102,10 +102,10 @@ create_format_terra_raster <- function(filetype, gdal, ...) { drv <- terra::gdal(drivers = TRUE) drv <- drv[drv$type == "raster" & grepl("write", drv$can), ] - filetype <- filetype %||% geotargets_option_get("raster.gdal_driver_name") + filetype <- filetype %||% geotargets_option_get("gdal.raster.driver_name") filetype <- rlang::arg_match0(filetype, drv$name) - gdal <- gdal %||% geotargets_option_get("raster.gdal_creation_options") + gdal <- gdal %||% geotargets_option_get("gdal.raster.creation_options") # NOTE: Option getting functions are set in the .write_terra_raster function template # to resolve issue with body<- not working in some evaluation contexts ({covr}). @@ -114,9 +114,9 @@ create_format_terra_raster <- function(filetype, gdal, ...) { terra::writeRaster( object, path, - filetype = geotargets::geotargets_option_get("raster.gdal_driver_name"), + filetype = geotargets::geotargets_option_get("gdal.raster.driver_name"), overwrite = TRUE, - gdal = geotargets::geotargets_option_get("raster.gdal_creation_options") + gdal = geotargets::geotargets_option_get("gdal.raster.creation_options") ) } diff --git a/man/geotargets-options.Rd b/man/geotargets-options.Rd index b79777f..91e4e40 100644 --- a/man/geotargets-options.Rd +++ b/man/geotargets-options.Rd @@ -20,14 +20,14 @@ Get or set behavior for geospatial data target stores using geotargets-specific \details{ \subsection{Available Options}{ \itemize{ -\item \code{"geotargets.raster.gdal_creation_options"} - set the GDAL creation options used when writing raster files to target store (default: \code{"ENCODING=UTF-8"}) -\item \code{"geotargets.raster.gdal_driver_name"} - set the file type used for raster data in target store (default: \code{"GTiff"}) +\item \code{"geotargets.gdal.raster.creation_options"} - set the GDAL creation options used when writing raster files to target store (default: \code{"ENCODING=UTF-8"}) +\item \code{"geotargets.gdal.raster.driver_name"} - set the file type used for raster data in target store (default: \code{"GTiff"}) } Each option can be overridden with a system environment variable. Options include: \itemize{ -\item \code{GEOTARGETS_RASTER_GDAL_CREATION_OPTIONS} -\item \code{GEOTARGETS_RASTER_GDAL_DRIVER_NAME} +\item \code{GEOTARGETS_GDAL_RASTER_CREATION_OPTIONS} +\item \code{GEOTARGETS_GDAL_RASTER_DRIVER_NAME} } } }