Skip to content

Commit

Permalink
ad4gd: improve .rds naming due to duplicated
Browse files Browse the repository at this point in the history
lake names (i.e. one lake name sometimes has different shapes, which occurs for 29/295 lakes of Malte`s Brandenburg selection

to do:
improve debug messages for gee_get_data() and gee_get_data_for_years()
  • Loading branch information
mrustl committed May 22, 2024
1 parent 10f0886 commit 08f9bbd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 13 deletions.
8 changes: 4 additions & 4 deletions R/google-earth-engine_copernicus_get-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param via via (default: "getInfo"), other options use google cloud (google drive
#' or google cloud storage)
#' @param col_lakename col_lakename ("GEWNAME", used by Berlin authority for surface
#' water bodies)
#' water bodies) use "SEE_NAME" for Brandenburg lakes (default: "SEE_NAME")
#' @param debug print debug messages? (default: TRUE)
#' @param ee_print show debug messages for "ee" (default: FALSE)
#' @param n_year_splits number of year splits per request. Required in case request
Expand All @@ -34,7 +34,7 @@ gee_get_data_for_years <- function(years = 2018,
spatial_fun = "mean",
scale = 10,
via = "getInfo",
col_lakename = "GEWNAME",
col_lakename = "SEE_NAME",
debug = TRUE,
ee_print = FALSE,
n_year_splits = NULL) {
Expand Down Expand Up @@ -157,7 +157,7 @@ gee_get_data_for_years <- function(years = 2018,
#' \url{https://developers.google.com/earth-engine/guides/scale}
#' @param via via (default: "getInfo"), other options use google cloud storage
#' @param col_lakename col_lakename ("GEWNAME", used by Berlin authority for surface
#' water bodies)
#' water bodies) use "SEE_NAME" for Brandenburg lakes (default: "SEE_NAME")
#' @param debug print debug messages? (default: TRUE)
#'
#' @return tibble
Expand All @@ -177,7 +177,7 @@ gee_get_data <- function (collection,
spatial_fun = "mean",
scale = 10,
via = "getInfo",
col_lakename = "GEWNAME",
col_lakename = "SEE_NAME",
debug = TRUE) {

stopifnot(spatial_fun %in% names(rgee::ee$Reducer))
Expand Down
24 changes: 21 additions & 3 deletions R/google-earth-engine_copernicus_get-data_parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
#' @param via via (default: "getInfo"), other options use google cloud (google drive
#' or google cloud storage)
#' @param col_lakename col_lakename ("GEWNAME", used by Berlin authority for surface
#' water bodies) use "SEE_NAME" for Brandenburg lakes
#' water bodies) use "SEE_NAME" for Brandenburg lakes (default: "SEE_NAME")
#' @param col_lakeid ("GEWRNEU", used by Berlin authority for surface
#' water bodies) use "SEE_KZ" for Brandenburg lakes (default: "SEE_KZ")
#' @param set_lakenames_as_list_indices should lake names of "col_lakename" be used
#' for naming result list? (default: TRUE)
#' @param debug show debug messages (default: TRUE)
Expand Down Expand Up @@ -49,7 +51,8 @@ gee_get_data_for_years_parallel <- function(
spatial_fun = "mean",
scale = 10,
via = "getInfo",
col_lakename = "GEWNAME",
col_lakename = "SEE_NAME",
col_lakeid = "SEE_KZ",
set_lakenames_as_list_indices = TRUE,
debug = TRUE,
debug_dir = tempdir(),
Expand Down Expand Up @@ -127,9 +130,24 @@ gee_get_data_for_years_parallel <- function(

return_obj <- NULL


lake_idx <- if(is.null(lakes[[col_lakeid]][idx])) {
sprintf(paste0("%0", nchar(nrow(lakes_bb_selected)), "d_"), idx)
} else {
""
}

lake_id <- if(!is.null(lakes[[col_lakeid]][idx])) {
paste0(lakes[[col_lakeid]][idx], "_")
} else {
""
}

if(export_rds && not_failed) {
rds_name <- sprintf("%s_%s_%s_scale-%dm_%4d-%4d.rds",
rds_name <- sprintf("%s%s_%s%s_%s_scale-%dm_%4d-%4d.rds",
lake_idx,
lakes[[col_lakename]][idx],
lake_id,
shape_type,
spatial_fun,
scale,
Expand Down
4 changes: 2 additions & 2 deletions man/gee_get_data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/gee_get_data_for_years.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions man/gee_get_data_for_years_parallel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 08f9bbd

Please sign in to comment.