From b2a78ab85d2cfc38ffc060037be279ff0ae9400c Mon Sep 17 00:00:00 2001 From: Daphne Virlar-Knight Date: Wed, 19 Oct 2022 16:19:45 -0700 Subject: [PATCH 1/4] raster helper function edits: attributeList Changed the usage of an attributes data frame to a listed attributeList within the function, and edited the documentation to reflect those changes. --- R/eml.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/eml.R b/R/eml.R index ba5e01c..f51c1e3 100644 --- a/R/eml.R +++ b/R/eml.R @@ -461,11 +461,11 @@ extract_name <- function(x){ #' #' @param path (char) Path to a raster file #' @param coord_name (char) horizCoordSysDef name -#' @param attributes (dataTable) attributes for raster +#' @param attributeList (list) Entity attributeList for raster #' #' #' @export -eml_get_raster_metadata <- function(path, coord_name = NULL, attributes){ +eml_get_raster_metadata <- function(path, coord_name = NULL, attributeList){ raster_obj <- raster::raster(path) message(paste("Reading raster object with proj4string of ", raster::crs(raster_obj)@projargs)) @@ -483,7 +483,7 @@ eml_get_raster_metadata <- function(path, coord_name = NULL, attributes){ } raster_info <- list(entityName = basename(path), - attributeList = set_attributes(attributes), + attributeList = attributeList, spatialReference = list(horizCoordSysName = coord_name), horizontalAccuracy = list(accuracyReport = "unknown"), verticalAccuracy = list(accuracyReport = "unknown"), From 3c23dba5e6584b20baf7493562f3f592d22dc49d Mon Sep 17 00:00:00 2001 From: Daphne Virlar-Knight Date: Wed, 19 Oct 2022 17:30:03 -0700 Subject: [PATCH 2/4] raster helper function edits: coord_name argument Added a warning message if the coord_name argument is NULL. Warning message alerts users that EML won't validate, and provides correct string for commonly used WGS84 and NAD83 datums. Also directs users to the get_coord_list() for more information. --- R/eml.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/eml.R b/R/eml.R index f51c1e3..bb1a2a1 100644 --- a/R/eml.R +++ b/R/eml.R @@ -471,7 +471,8 @@ eml_get_raster_metadata <- function(path, coord_name = NULL, attributeList){ message(paste("Reading raster object with proj4string of ", raster::crs(raster_obj)@projargs)) if (is.null(coord_name)){ - coord_name <- raster::crs(raster_obj)@projargs + #coord_name <- raster::crs(raster_obj)@projargs + warning(paste("Error in the 'coord_name' argument. The following coordinate string will not allow the EML to validate if used:", raster::crs(raster_obj)@projargs, "\n \nPlease search for the appropriate coordinate string by running View(get_coord_list()). You should use a string from the 'geogCoordSys' column. Commonly used projections are WGS84 and NAD83. The correct strings for these projections are 'GCS_WGS_1984' and 'GCS_North_American_1983', respectively.")) } From 908f7260fb04e56ccf3910d8112df0b329db1994 Mon Sep 17 00:00:00 2001 From: Daphne Virlar-Knight Date: Wed, 19 Oct 2022 17:35:45 -0700 Subject: [PATCH 3/4] Removed message; redundant with new error message --- R/eml.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/eml.R b/R/eml.R index bb1a2a1..d248c25 100644 --- a/R/eml.R +++ b/R/eml.R @@ -468,7 +468,7 @@ extract_name <- function(x){ eml_get_raster_metadata <- function(path, coord_name = NULL, attributeList){ raster_obj <- raster::raster(path) - message(paste("Reading raster object with proj4string of ", raster::crs(raster_obj)@projargs)) + # message(paste("Reading raster object with proj4string of ", raster::crs(raster_obj)@projargs)) if (is.null(coord_name)){ #coord_name <- raster::crs(raster_obj)@projargs From 44236e9294ebde3c09d1a77acee3dedb3ed6fc47 Mon Sep 17 00:00:00 2001 From: Daphne Virlar-Knight Date: Wed, 19 Oct 2022 17:37:56 -0700 Subject: [PATCH 4/4] Raster function: replaced coordinate origin selections --- R/eml.R | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/R/eml.R b/R/eml.R index d248c25..1c02878 100644 --- a/R/eml.R +++ b/R/eml.R @@ -476,11 +476,28 @@ eml_get_raster_metadata <- function(path, coord_name = NULL, attributeList){ } - if (identical(raster::origin(raster_obj), c(0,0))){ + if (raster::origin(raster_obj)[1] > 0 & raster::origin(raster_obj)[2] > 0 ){ + # positive x, positive y + raster_orig <- "Upper Right" + } else if (raster::origin(raster_obj)[1] < 0 & raster::origin(raster_obj)[2] > 0 ){ + # negative x, positive y + raster_orig <- "Upper Left" + } else if (raster::origin(raster_obj)[1] < 0 & raster::origin(raster_obj)[2] < 0 ){ + # negative x, negative y + raster_orig <- "Lower Left" + } else if (raster::origin(raster_obj)[1] > 0 & raster::origin(raster_obj)[2] < 0 ){ + # positive x, negative y + raster_orig <- "Lower Right" + } else if (raster::origin(raster_obj)[1] == 0 & raster::origin(raster_obj)[2] < 0 ){ + raster_orig <- "Lower Left" + } else if (raster::origin(raster_obj)[1] == 0 & raster::origin(raster_obj)[2] > 0 ){ + raster_orig <- "Upper Left" + } else if (raster::origin(raster_obj)[1] > 0 & raster::origin(raster_obj)[2] == 0 ){ + raster_orig <- "Upper Right" + } else if (raster::origin(raster_obj)[1] < 0 & raster::origin(raster_obj)[2] == 0 ){ + raster_orig <- "Upper Left" + } else if (identical(raster::origin(raster_obj), c(0,0))){ raster_orig <- "Upper Left" - } else if(!identical(raster::origin(raster_obj), c(0,0))){ - message("Raster origin not at 0,0") - raster_orig <- "unknown" } raster_info <- list(entityName = basename(path),