diff --git a/NAMESPACE b/NAMESPACE index 22b331f8..c2e30bd4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -54,17 +54,6 @@ export(ee_manage_set_properties) export(ee_manage_task) export(ee_monitoring) export(ee_print) -export(ee_search_dataset) -export(ee_search_display) -export(ee_search_enddate) -export(ee_search_provider) -export(ee_search_provider_list) -export(ee_search_startdate) -export(ee_search_tags) -export(ee_search_tagstitle) -export(ee_search_title) -export(ee_search_title_list) -export(ee_search_type) export(ee_table_to_asset) export(ee_table_to_drive) export(ee_table_to_gcs) diff --git a/R/Deprecated.R b/R/Deprecated.R index 9924f692..e69de29b 100755 --- a/R/Deprecated.R +++ b/R/Deprecated.R @@ -1,301 +0,0 @@ -#' Interface to search into the Earth Engine Data Catalog -#' -#' R functions for searching in Earth Engine's public data archive. -#' -#' @param quiet logical. Suppress info message -#' @param ee_search_dataset data.frame generated by rgee::ee_search_Datasets() -#' or a character which represents the EE dataset ID. -#' @param stardate Character. Start date of dataset availability. -#' @param enddate Character. End date of dataset availability. -#' @param provider Character. Name of the dataset's provider. See -#' ee_search_provider_list() -#' @param type Character. "Image", "ImageCollection" or a "table". -#' @param ... Character vector. tags -#' @param logical_operator Character. Available just for rgee::ee_search_tags -#' and rgee::ee_search_title. 'AND' represents inclusiveness between tags in -#' searching and 'OR' exclusiveness. -#' @param upgrade Logical. If the dataset needs to be upgraded. -#' @param maxdisplay Numeric. Maximum number of tabs to display in their browser -#' @param path_dataset Path of the dataset. By default it will loaded -#' automatically. -#' @name ee_search-tools -#' @return A data.frame where rows represents public data archive. -#' @examples -#' \dontrun{ -#' library(rgee) -#' ee_Initialize() -#' -#' # ee_search_provider_list() -#' # ee_search_title_list() -#' myquery <- ee_search_dataset() %>% -#' ee_search_type("Image") %>% -#' ee_search_provider("WWF") %>% -#' ee_search_tags("srtm", "flow", "direction", "dem") %>% -#' ee_search_title("15", "Flow", logical_operator = "AND") %>% -#' ee_search_display() -#' } -#' @export -ee_search_dataset <- function(quiet = FALSE, - upgrade = FALSE, - path_dataset = NULL) { - message_deprecated <- c( - "\"ee_search_dataset\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_dataset", msg = message_deprecated) - - oauth_func_path <- system.file("python/ee_utils.py", package = "rgee") - utils_py <- ee_source_python(oauth_func_path) - ee_path <- ee_utils_py_to_r(utils_py$ee_path()) - ee_search_dataset_file <- sprintf( - "%s/ee_search_dataset.csv", - ee_path - ) - if (file.exists(ee_search_dataset_file) & !upgrade) { - ee_search_dataset <- read.csv(ee_search_dataset_file, - stringsAsFactors = FALSE) - } else { - if (is.null(path_dataset)) { - user_samapriya <- "https://raw.githubusercontent.com/csaybar/" - ee_template <- "%sEarth-Engine-Datasets-List/master/%s" - ee_search_dataset_uri <- sprintf(ee_template, user_samapriya, - find_eedataset()) - } else { - ee_search_dataset_uri <- path_dataset - } - ee_search_dataset <- read.csv(ee_search_dataset_uri, - stringsAsFactors = FALSE) - if (!quiet) { - cat("Downloading(Upgrading) the Earth Engine catalog ... please wait\n") - } - write.csv( - x = ee_search_dataset, - file = ee_search_dataset_file, - row.names = FALSE - ) - } - return(ee_search_dataset) -} - -#' @name ee_search-tools -#' @export -ee_search_startdate <- function(ee_search_dataset, stardate) { - message_deprecated <- c( - "\"ee_search_startdate\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_startdate", msg = message_deprecated) - - m <- gregexpr("[\\w']+", ee_search_dataset$start_date, perl = TRUE) - ee_start_date <- ee_search_dataset$start_date %>% - regmatches(m) %>% - lapply(fix_date) - m <- do.call(c, m) - stardate <- as.Date(stardate) - ee_search_dataset_q <- ee_search_dataset[which(ee_start_date > stardate), ] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) -} - -#' @name ee_search-tools -#' @export -ee_search_enddate <- function(ee_search_dataset, enddate = Sys.Date()) { - message_deprecated <- c( - "\"ee_search_enddate\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_enddate", msg = message_deprecated) - m <- gregexpr("[\\w']+", ee_search_dataset$end_date, perl = TRUE) - ee_end_date <- ee_search_dataset$end_date %>% - regmatches(m) %>% - lapply(fix_date) - m <- do.call(c, m) - enddate <- as.Date(enddate) - ee_search_dataset_q <- ee_search_dataset[which(ee_end_date < enddate), ] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) -} - -#' @name ee_search-tools -#' @export -ee_search_type <- function(ee_search_dataset, type) { - message_deprecated <- c( - "\"ee_search_type\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_type", msg = message_deprecated) - ee_search_dataset_type <- tolower(ee_search_dataset$type) - type <- tolower(type) - if (type %in% unique(ee_search_dataset_type)) { - ee_search_dataset_q <- ee_search_dataset[ee_search_dataset_type %in% type, ] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) - } else { - stop("type argument is not valid") - } -} - -#' @name ee_search-tools -#' @export -ee_search_provider <- function(ee_search_dataset, provider) { - message_deprecated <- c( - "\"ee_search_provider\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_provider", msg = message_deprecated) - if (provider %in% unique(ee_search_dataset$provider)) { - condition <- ee_search_dataset$provider %in% provider - ee_search_dataset_q <- ee_search_dataset[condition,] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) - } else { - stop("provider argument is not valid") - } -} - -#' @name ee_search-tools -#' @export -ee_search_provider_list <- function(ee_search_dataset) { - message_deprecated <- c( - "\"ee_search_provider_list\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_provider_list", msg = message_deprecated) - return(unique(ee_search_dataset$provider)) -} - -#' @name ee_search-tools -#' @export -ee_search_tags <- function(ee_search_dataset, ..., logical_operator = "OR") { - message_deprecated <- c( - "\"ee_search_tags\" will not be available for rgee version 1.0.8 ." - ) - .Deprecated("ee_search_tags", msg = message_deprecated) - tags <- tolower(c(...)) - ee_tags <- tolower(ee_search_dataset$tags) - if (logical_operator == "OR") { - cond <- mapply(function(x) grepl(x, ee_tags), tags) %>% apply(1, any) - } else if (logical_operator == "AND") { - cond <- mapply(function(x) grepl(x, ee_tags), tags) %>% apply(1, all) - } else { - stop("logical_operator argument is not valid") - } - ee_search_dataset_q <- ee_search_dataset[cond, ] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) -} - -#' @name ee_search-tools -#' @export -ee_search_title <- function(ee_search_dataset, ..., logical_operator = "OR") { - message_deprecated <- c( - "\"ee_search_title\" will not be available for rgee version 1.0.8." - ) - .Deprecated("ee_search_title", msg = message_deprecated) - tags <- tolower(c(...)) - ee_title <- tolower(ee_search_dataset$title) - if (logical_operator == "OR") { - cond <- mapply(function(x) grepl(x, ee_title), tags) %>% apply(1, any) - } else if (logical_operator == "AND") { - cond <- mapply(function(x) grepl(x, ee_title), tags) %>% apply(1, all) - } else { - stop("logical_operator argument is not valid") - } - ee_search_dataset_q <- ee_search_dataset[cond, ] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) -} - - -#' @name ee_search-tools -#' @export -ee_search_tagstitle <- function(ee_search_dataset, ..., - logical_operator = "OR") { - message_deprecated <- c( - "\"ee_search_tagstitle\" will not be available for rgee version 1.0.8." - ) - .Deprecated("ee_search_tagstitle", msg = message_deprecated) - - tags <- tolower(c(...)) - ee_title <- tolower(ee_search_dataset$title) - ee_tags <- tolower(ee_search_dataset$tags) - if (logical_operator == "OR") { - cond_1 <- mapply(function(x) grepl(x, ee_title), tags) %>% apply(1, any) - cond_2 <- mapply(function(x) grepl(x, ee_tags), tags) %>% apply(1, any) - cond_3 <- mapply(any, cond_1, cond_2) - } else if (logical_operator == "AND") { - cond_1 <- mapply(function(x) grepl(x, ee_title), tags) %>% apply(1, all) - cond_2 <- mapply(function(x) grepl(x, ee_tags), tags) %>% apply(1, all) - cond_3 <- mapply(any, cond_1, cond_2) - } else { - stop("logical_operator argument is not valid") - } - ee_search_dataset_q <- ee_search_dataset[cond_3, ] - rownames(ee_search_dataset_q) <- NULL - return(ee_search_dataset_q) -} - -#' @name ee_search-tools -#' @export -ee_search_title_list <- function(ee_search_dataset) { - message_deprecated <- c( - "\"ee_search_title_list\" will not be available for rgee version 1.0.8." - ) - .Deprecated("ee_search_title_list", msg = message_deprecated) - return(unique(ee_search_dataset$provider)) -} - -#' Change the date format -#' @noRd -fix_date <- function(x) { - month <- x[1] - day <- x[2] - year <- x[3] - if (nchar(year) == 2 & as.integer(year) > 50) { - year <- 1900 + as.integer(year) - } else if (nchar(year) == 2 & as.integer(year) <= 50) { - year <- 2000 + as.integer(year) - } else { - year <- as.integer(year) - } - final_date <- as.Date(sprintf("%s-%s-%s", year, month, day)) - return(final_date) -} - -#' @name ee_search-tools -#' @export -ee_search_display <- function(ee_search_dataset, maxdisplay = 10) { - message_deprecated <- c( - "\"ee_search_title_list\" will not be available for rgee version 1.0.8.", - " Use ee_utils_search_display instead." - ) - .Deprecated("ee_search_title_list", msg = message_deprecated) - - if (is.character(ee_search_dataset)) { - tag_name <- gsub("\\/", "_", ee_search_dataset) - } else { - tag_name <- gsub("\\/", "_", ee_search_dataset$id) - } - db_catalog <- "https://developers.google.com/earth-engine/datasets/catalog/" - catalog_uri <- paste0(db_catalog, tag_name) %>% - "["(1:maxdisplay) %>% - na.omit() %>% - as.character() - for (uri in catalog_uri) { - browseURL(uri) - } - invisible(TRUE) -} - -#' Find the EE Dataset List on GitHub -#' @noRd -find_eedataset <- function() { - message_deprecated <- c( - "\"ee_search_title_list\" will not be available for rgee version 1.0.8." - ) - .Deprecated("ee_search_title_list", msg = message_deprecated) - - if (!requireNamespace("httr", quietly = TRUE)) { - stop("package httr required, please install it first") - } - git_repo <- "https://api.github.com/repos/csaybar/Earth-Engine-Datasets-List/" - req <- httr::GET(sprintf("%s/git/trees/master?recursive=1", git_repo)) - httr::stop_for_status(req) - filelist <- lapply(httr::content(req)$tree, "[", "path") - filelist <- unlist(filelist, use.names = FALSE) - filelist[grepl("eed", filelist)] -} diff --git a/R/Map.R b/R/Map.R index c29c5287..ce384b84 100755 --- a/R/Map.R +++ b/R/Map.R @@ -147,17 +147,7 @@ #' name = "SF" #' ) #' -#' # Case 5: mapview + EarthEnginemap -#' # library(mapview) -#' # library(sf) -#' # nc <- st_read(system.file("shp/arequipa.shp", package="rgee")) -#' # mapview(nc, m2) -#' -#' # Case 6: mapedit -#' # library(mapedit) -#' # my_geometry <- m4 %>% editMap() -#' -#' # Case 7: ImageCollection +#' # Case 5: ImageCollection #' nc <- st_read(system.file("shape/nc.shp", package = "sf")) %>% #' st_transform(4326) %>% #' sf_as_ee() @@ -170,7 +160,7 @@ #' m5 <- Map$addLayers(ee_s2, legend = TRUE) #' m5 #' -#' # Case 8: Map comparison +#' # Case 6: Map comparison #' image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318") #' Map$centerObject(image) #' m_ndvi <- Map$addLayer( @@ -182,7 +172,7 @@ #' m6 <- m4 | m_ndvi #' m6 #' -#' # Case 9: digging up the metadata +#' # Case 7: digging up the metadata #' m6$rgee$tokens #' m5$rgee$tokens #' } diff --git a/R/ee_Initialize.R b/R/ee_Initialize.R index 3c14e7ba..b1aafc56 100755 --- a/R/ee_Initialize.R +++ b/R/ee_Initialize.R @@ -36,21 +36,13 @@ #' called \code{~/.config/earthengine/ndef}. #' #' @family session management functions -#' +#' @return No return value, called for initializing the earthengine-api. #' @examples #' \dontrun{ #' library(rgee) #' #' # Simple init - Load just the Earth Engine credential #' ee_Initialize() -#' -#' # Advanced init - Load full credentials -#' # ee_Initialize( -#' # email = "your_email@gmail.com", -#' # drive = TRUE, -#' # gcs = TRUE -#' # ) -#' #' ee_user_info() #' } #' @export @@ -495,7 +487,7 @@ ee_users <- function(quiet = FALSE) { #' Display the credentials and general info of the initialized user #' @family session management functions -#' +#' @return A list with information about the Earth Engine user. #' @param quiet Logical. Suppress info messages. #' #' @examples @@ -557,8 +549,8 @@ ee_user_info <- function(quiet = FALSE) { cat("\n - ",basename(gcs)) cat("\n", rule(), "\n") } - ee_user <- ee_exist_credentials() + # ee_user <- ee_exist_credentials() # if (isFALSE(grepl(email_drive, ee_user$email)) & ee_user$email != "ndef") { # message( # "\nNOTE: Google Drive credential does not match with your Google", @@ -568,7 +560,12 @@ ee_user_info <- function(quiet = FALSE) { # } ee_check_python_packages(quiet = TRUE) - invisible(TRUE) + list( + asset_home = asset_home, + user_session = user_session, + gd_id = basename(gd), + gcs_file = gcs + ) } #' Create session info of the last init inside the diff --git a/R/ee_as_sf.R b/R/ee_as_sf.R index 931a7852..f1a266ba 100755 --- a/R/ee_as_sf.R +++ b/R/ee_as_sf.R @@ -120,11 +120,11 @@ #' ) #' #' # Download via GCS -#' # sf_randomPoints_gcs <- ee_as_sf( -#' # x = subset, -#' # via = 'gcs', -#' # container = 'rgee_dev' #GCS bucket name -#' # ) +#' sf_randomPoints_gcs <- ee_as_sf( +#' x = subset, +#' via = 'gcs', +#' container = 'rgee_dev' #GCS bucket name +#' ) #' } #' @export ee_as_sf <- function(x, diff --git a/R/ee_check.R b/R/ee_check.R index c26fda07..8cf2f204 100755 --- a/R/ee_check.R +++ b/R/ee_check.R @@ -15,6 +15,7 @@ #' @importFrom crayon yellow #' @importFrom cli cat_line #' @family ee_check functions +#' @return No return value, called for checking non-R rgee dependencies. #' @examples #' \dontrun{ #' library(rgee) @@ -31,6 +32,7 @@ ee_check <- function(user = NULL, quiet = FALSE) { if (!is.null(user)) { ee_check_credentials(quiet = quiet) } + invisible(TRUE) } #' @rdname ee_check-tools diff --git a/R/ee_clean.R b/R/ee_clean.R index 94936b09..0e05798d 100755 --- a/R/ee_clean.R +++ b/R/ee_clean.R @@ -7,15 +7,9 @@ #' #' @param email Character. Earth Engine user (e.g. `data.colec.fbf`). #' @param quiet Logical. Suppress info messages. +#' @return No return value, called for cleaning Google Drive, Google Cloud Storage, +#' and/or Earth Engine credentials. #' @family ee_clean functions -#' @examples -#' \dontrun{ -#' library(rgee) -#' -#' # ee_clean_credentials() -#' # ee_clean_credentials('data.colec.fbf@gmail.com') -#' -#' } #' @export ee_clean_credentials <- function(email='not_defined', quiet = FALSE) { oauth_func_path <- system.file("python/ee_utils.py", package = "rgee") @@ -53,11 +47,7 @@ ee_clean_credentials <- function(email='not_defined', quiet = FALSE) { #' Remove rgee system variables from .Renviron #' #' @family ee_clean functions -#' @examples -#' \dontrun{ -#' # library(rgee) -#' # ee_clean_pyenv() -#' } +#' @return No return value, called for cleaning environmental variables in their system. #' @export ee_clean_pyenv <- function() { # Read line by line .Renviron @@ -135,6 +125,7 @@ ee_clean_message <- function() { #' @param type Character. Name of the file storage web service. 'drive' #' and 'gcs' are supported. #' @param quiet logical. Suppress info message +#' @return No return value, called for cleaning Google Drive or Google Cloud Storage container. #' @family ee_clean functions #' #' @export diff --git a/R/ee_download.R b/R/ee_download.R index 150bb53f..0b10a31d 100755 --- a/R/ee_download.R +++ b/R/ee_download.R @@ -245,20 +245,20 @@ ee_image_to_drive <- function(image, #' mean_l5_Amarakaeri <- mean_l5$clip(ee_ROI) #' #' # Move results from Earth Engine to GCS -#' # task_img <- ee_image_to_gcs( -#' # image = mean_l5_Amarakaeri, -#' # bucket = "rgee_dev", -#' # fileFormat = "GEO_TIFF", -#' # region = ee_ROI, -#' # fileNamePrefix = "my_image_demo" -#' # ) -#' # -#' # task_img$start() -#' # ee_monitoring(task_img) +#' task_img <- ee_image_to_gcs( +#' image = mean_l5_Amarakaeri, +#' bucket = "rgee_dev", +#' fileFormat = "GEO_TIFF", +#' region = ee_ROI, +#' fileNamePrefix = "my_image_demo" +#' ) +#' +#' task_img$start() +#' ee_monitoring(task_img) #' #' # Move results from GCS to local -#' # ee_gcs_to_local(task = task_img) -#' # plot(img) +#' ee_gcs_to_local(task = task_img) +#' #' } #' @export ee_image_to_gcs <- function(image, @@ -577,16 +577,16 @@ ee_table_to_drive <- function(collection, #' list(ee$Feature(ee_ROI, list(name = "Amarakaeri"))) #' ) #' -#' #task_vector <- ee_table_to_gcs( -#' # collection = amk_fc, -#' # bucket = "rgee_dev", -#' # fileFormat = "SHP", -#' # fileNamePrefix = "geom_Amarakaeri" -#' #) -#' #task_vector$start() -#' #ee_monitoring(task_vector) # optional -#' #amk_geom <- ee_gcs_to_local(task = task_vector) -#' #plot(sf::read_sf(amk_geom[3]), border = "red", lwd = 10) +#' task_vector <- ee_table_to_gcs( +#' collection = amk_fc, +#' bucket = "rgee_dev", +#' fileFormat = "SHP", +#' fileNamePrefix = "geom_Amarakaeri" +#' ) +#' task_vector$start() +#' ee_monitoring(task_vector) # optional +#' amk_geom <- ee_gcs_to_local(task = task_vector) +#' plot(sf::read_sf(amk_geom[3]), border = "red", lwd = 10) #' } #' @export ee_table_to_gcs <- function(collection, @@ -1002,20 +1002,20 @@ ee_drive_to_local <- function(task, #' mean_l5 <- mean_l5$reproject(crs = "EPSG:4326", scale = 500) #' mean_l5_Amarakaeri <- mean_l5$clip(ee_ROI) #' -#' ## Move results from Earth Engine to Drive -#' # task_img <- ee_image_to_gcs( -#' # image = mean_l5_Amarakaeri, -#' # bucket = "rgee_dev", -#' # fileFormat = "GEO_TIFF", -#' # region = ee_ROI, -#' # fileNamePrefix = "my_image_demo" -#' #) +#' # Move results from Earth Engine to Drive +#' task_img <- ee_image_to_gcs( +#' image = mean_l5_Amarakaeri, +#' bucket = "rgee_dev", +#' fileFormat = "GEO_TIFF", +#' region = ee_ROI, +#' fileNamePrefix = "my_image_demo" +#' ) #' -#' # task_img$start() -#' # ee_monitoring(task_img) +#' task_img$start() +#' ee_monitoring(task_img) #' -#' ## Move results from Drive to local -#' # img <- ee_gcs_to_local(task = task_img) +#' # Move results from Drive to local +#' img <- ee_gcs_to_local(task = task_img) #' } #' @export ee_gcs_to_local <- function(task, diff --git a/R/ee_help.R b/R/ee_help.R index b6f3bbc7..928908bf 100755 --- a/R/ee_help.R +++ b/R/ee_help.R @@ -4,6 +4,7 @@ #' @importFrom reticulate py_function_docs #' @importFrom utils tail #' @family helper functions +#' @return No return value, called for displaying Earth Engine documentation. #' @examples #' \dontrun{ #' library(rgee) @@ -137,16 +138,15 @@ ee_help <- function(eeobject, browser = FALSE) { #' Create init table - R Documentation Simple #' @noRd ee_html_head_simple <- function(fun_name) { - ' + message <- '
-
fun_rgee {rgee} R Documentation
' -> message - message <- gsub(" -", "", message) + ' + message <- gsub("\n", "", message) gsub("fun_rgee", fun_name, message) } @@ -154,16 +154,15 @@ ee_html_head_simple <- function(fun_name) { #' @noRd ee_html_head_rstudio <- function(fun_name) { td_style <- "font-family: sans-serif;font-size: 10pt;" - ' + message <- '
-
fun_rgee {rgee} R Documentation
' -> message - message <- gsub(" -", "", message) + ' + message <- gsub("\n", "", message) message_norgee <- gsub("fun_rgee", fun_name, message) gsub("td_style", td_style, message_norgee) } diff --git a/R/ee_image.R b/R/ee_image.R index 431153ef..8888ca99 100755 --- a/R/ee_image.R +++ b/R/ee_image.R @@ -120,31 +120,30 @@ #' img_02_result <- img_02 %>% ee_utils_future_value() #' attr(img_02_result, "metadata") # metadata #' -#' # ## gcs - Method 02 -#' # # Simple -#' # img_03 <- ee_as_stars( -#' # image = img, -#' # region = geometry, -#' # container = "rgee_dev", -#' # via = "gcs" -#' # ) -#' # -#' # # Lazy -#' # img_03 <- ee_as_stars( -#' # image = img, -#' # region = geometry, -#' # container = "rgee_dev", -#' # lazy = TRUE, -#' # via = "gcs" -#' # ) -#' # -#' # img_03_result <- img_03 %>% ee_utils_future_value() -#' # attr(img_03_result, "metadata") # metadata -#' # -#' # -#' # # OPTIONAL: clean containers -#' # ee_clean_container(name = "rgee_backup", type = "drive") -#' # ee_clean_container(name = "rgee_dev", type = "gcs") +#' ## gcs - Method 02 +#' # Simple +#' img_03 <- ee_as_stars( +#' image = img, +#' region = geometry, +#' container = "rgee_dev", +#' via = "gcs" +#' ) +#' +#' # Lazy +#' img_03 <- ee_as_stars( +#' image = img, +#' region = geometry, +#' container = "rgee_dev", +#' lazy = TRUE, +#' via = "gcs" +#' ) +#' +#' img_03_result <- img_03 %>% ee_utils_future_value() +#' attr(img_03_result, "metadata") # metadata +#' +#' # OPTIONAL: clean containers +#' ee_clean_container(name = "rgee_backup", type = "drive") +#' ee_clean_container(name = "rgee_dev", type = "gcs") #' } #' @export ee_as_stars <- function(image, @@ -335,30 +334,30 @@ ee_as_stars <- function(image, #' img_02_result <- img_02 %>% ee_utils_future_value() #' img_02_result@history$metadata # metadata #' -#' # ## gcs - Method 02 -#' # # Simple -#' # img_03 <- ee_as_raster( -#' # image = img, -#' # region = geometry, -#' # container = "rgee_dev", -#' # via = "gcs" -#' # ) -#' # -#' # # Lazy -#' # img_03 <- ee_as_raster( -#' # image = img, -#' # region = geometry, -#' # container = "rgee_dev", -#' # lazy = TRUE, -#' # via = "gcs" -#' # ) -#' # -#' # img_03_result <- img_03 %>% ee_utils_future_value() -#' # img_03_result@history$metadata # metadata +#' ## gcs - Method 02 +#' # Simple +#' img_03 <- ee_as_raster( +#' image = img, +#' region = geometry, +#' container = "rgee_dev", +#' via = "gcs" +#' ) +#' +#' # Lazy +#' img_03 <- ee_as_raster( +#' image = img, +#' region = geometry, +#' container = "rgee_dev", +#' lazy = TRUE, +#' via = "gcs" +#' ) +#' +#' img_03_result <- img_03 %>% ee_utils_future_value() +#' img_03_result@history$metadata # metadata #' #' # OPTIONAL: clean containers -#' # ee_clean_container(name = "rgee_backup", type = "drive") -#' # ee_clean_container(name = "rgee_dev", type = "gcs") +#' ee_clean_container(name = "rgee_backup", type = "drive") +#' ee_clean_container(name = "rgee_dev", type = "gcs") #' } #' @export ee_as_raster <- function(image, diff --git a/R/ee_install.R b/R/ee_install.R index b97f13fe..9165fedf 100755 --- a/R/ee_install.R +++ b/R/ee_install.R @@ -25,12 +25,8 @@ #' @param earthengine_version Character. The Earth Engine Python API version #' to install. By default \code{rgee::ee_version()}. #' @param confirm Logical. Confirm before restarting R?. +#' @return No return value, called for installing non-R dependencies. #' @family ee_install functions -#' @examples -#' \dontrun{ -#' # library(rgee) -#' # ee_install() #It is just necessary once -#' } #' @export ee_install <- function(py_env = "rgee", earthengine_version = ee_version(), @@ -252,6 +248,7 @@ ee_install <- function(py_env = "rgee", #' @param py_path The path to a Python interpreter #' @param py_env The name of the environment #' @param quiet Logical. Suppress info message +#' @return no return value, called for setting EARTHENGINE_PYTHON in .Renviron #' @family ee_install functions #' @export ee_install_set_pyenv <- function(py_path = NULL, py_env = NULL, quiet = FALSE) { @@ -396,6 +393,7 @@ is_windows <- function() { #' By default \code{rgee::ee_version()}. #' @param earthengine_env Character. The name, or full path, of the #' environment in which the earthengine-api packages are to be installed. +#' @return no return value, called to upgrade the earthengine-api Python package #' @family ee_install functions #' @export ee_install_upgrade <- function(version = NULL, diff --git a/R/ee_utils.R b/R/ee_utils.R index 3e5752b0..931f5941 100755 --- a/R/ee_utils.R +++ b/R/ee_utils.R @@ -187,8 +187,8 @@ ee_utils_pyfunc <- reticulate::py_func #' ee_utils_gif_annotate("created using {magick} + {rgee}", #' size = 15, font = "sans",location = "+70+20") -> #' animation_wtxt -#' animation_wtxt -#' # ee_utils_gif_save(animation_wtxt, path = "raster_as_ee.gif") +#' gc(reset = TRUE) +#' ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) #' } #' @family GIF functions #' @export @@ -291,8 +291,8 @@ ee_utils_gif_creator <- function(ic, parameters, quiet = FALSE, ...) { #' ee_utils_gif_annotate("created using {magick} + {rgee}", #' size = 15, font = "sans",location = "+70+20") -> #' animation_wtxt -#' animation_wtxt -#' # ee_utils_gif_save(animation_wtxt, path = "raster_as_ee.gif") +#' gc(reset = TRUE) +#' ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) #' } #' @family GIF functions #' @export @@ -403,10 +403,11 @@ ee_utils_gif_annotate <- function(image, #' ee_utils_gif_annotate("created using {magick} + {rgee}", #' size = 15, font = "sans",location = "+70+20") -> #' animation_wtxt -#' animation_wtxt -#' # ee_utils_gif_save(animation_wtxt, path = "raster_as_ee.gif") +#' gc(reset = TRUE) +#' ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) #' } #' @family GIF functions +#' @return No return value, called to write a GIF file. #' @export ee_utils_gif_save <- function(image, path = NULL, @@ -428,6 +429,7 @@ ee_utils_gif_save <- function(image, #' Search into the Earth Engine Data Catalog #' #' @param ee_search_dataset character which represents the EE dataset ID. +#' @return No return value, called for displaying the Earth Engine dataset in the browser. #' @examples #' \dontrun{ #' library(rgee) diff --git a/R/ee_version.R b/R/ee_version.R index 0e427a5d..38cce923 100755 --- a/R/ee_version.R +++ b/R/ee_version.R @@ -5,5 +5,5 @@ #' @return Character. Earth Engine Python API version used to build rgee. #' @export ee_version <- function() { - '0.1.247' + '0.1.248' } diff --git a/R/print.R b/R/print.R index c7d56f41..cb3286f8 100755 --- a/R/print.R +++ b/R/print.R @@ -3,6 +3,7 @@ #' @param ... ignored #' @param type Character. What to show about the x object?. Three options are #' supported: "json", "simply", "ee_print". By default "simply". +#' @return No return value, called for displaying Earth Engine objects. #' @export print.ee.computedobject.ComputedObject <- function(x, ..., type = getOption("rgee.print.option")) { diff --git a/R/raster_as_ee.R b/R/raster_as_ee.R index 26d1b914..5b4d45f6 100755 --- a/R/raster_as_ee.R +++ b/R/raster_as_ee.R @@ -24,36 +24,36 @@ #' x <- read_stars(tif) #' assetId <- sprintf("%s/%s",ee_get_assethome(),'stars_l7') #' -#' # # # Method 1 -#' # # 1. Move from local to gcs -#' # gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') -#' -#' # # 2. Create a manifest -#' # manifest <- ee_utils_create_manifest_image(gs_uri, assetId) -#' -#' # # 3. Pass from gcs to asset -#' # gcs_to_ee_image( -#' # manifest = manifest, -#' # overwrite = TRUE -#' # ) -#' -#' # # OPTIONAL: Monitoring progress -#' # ee_monitoring() -#' # -#' # # OPTIONAL: Display results -#' # ee_stars_01 <- ee$Image(assetId) -#' # Map$centerObject(ee_stars_01) -#' # Map$addLayer(ee_stars_01, list(min = 0, max = 255)) -#' # -#' # # Method 2 -#' # ee_stars_02 <- stars_as_ee( -#' # x = x, -#' # overwrite = TRUE, -#' # assetId = assetId, -#' # bucket = "rgee_dev" -#' # ) -#' # Map$centerObject(ee_stars_02) -#' # Map$addLayer(ee_stars_02, list(min = 0, max = 255)) +#' # # Method 1 +#' # 1. Move from local to gcs +#' gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') +#' +#' # 2. Create a manifest +#' manifest <- ee_utils_create_manifest_image(gs_uri, assetId) +#' +#' # 3. Pass from gcs to asset +#' gcs_to_ee_image( +#' manifest = manifest, +#' overwrite = TRUE +#' ) +#' +#' # OPTIONAL: Monitoring progress +#' ee_monitoring() +#' +#' # OPTIONAL: Display results +#' ee_stars_01 <- ee$Image(assetId) +#' Map$centerObject(ee_stars_01) +#' Map$addLayer(ee_stars_01, list(min = 0, max = 255)) +#' +#' # Method 2 +#' ee_stars_02 <- stars_as_ee( +#' x = x, +#' overwrite = TRUE, +#' assetId = assetId, +#' bucket = "rgee_dev" +#' ) +#' Map$centerObject(ee_stars_02) +#' Map$addLayer(ee_stars_02, list(min = 0, max = 255)) #' } #' @export stars_as_ee <- function(x, @@ -147,36 +147,36 @@ stars_as_ee <- function(x, #' x <- stack(tif) #' assetId <- sprintf("%s/%s",ee_get_assethome(),'raster_l7') #' -#' # # Method 1 -#' # # 1. Move from local to gcs -#' # gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') -#' # -#' # # 2. Create a manifest -#' # manifest <- ee_utils_create_manifest_image(gs_uri, assetId) -#' # -#' # # 3. Pass from gcs to asset -#' # gcs_to_ee_image( -#' # manifest = manifest, -#' # overwrite = TRUE -#' # ) -#' # -#' # # OPTIONAL: Monitoring progress -#' # ee_monitoring() -#' # -#' # # OPTIONAL: Display results -#' # ee_stars_01 <- ee$Image(assetId) -#' # Map$centerObject(ee_stars_01) -#' # Map$addLayer(ee_stars_02, list(min = 0, max = 255)) -#' # -#' # # Method 2 -#' # ee_stars_02 <- raster_as_ee( -#' # x = x, -#' # overwrite = TRUE, -#' # assetId = assetId, -#' # bucket = "rgee_dev" -#' # ) -#' # Map$centerObject(ee_stars_02) -#' # Map$addLayer(ee_stars_02, list(min = 0, max = 255)) +#' # Method 1 +#' # 1. Move from local to gcs +#' gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') +#' +#' # 2. Create a manifest +#' manifest <- ee_utils_create_manifest_image(gs_uri, assetId) +#' +#' # 3. Pass from gcs to asset +#' gcs_to_ee_image( +#' manifest = manifest, +#' overwrite = TRUE +#' ) +#' +#' # OPTIONAL: Monitoring progress +#' ee_monitoring() +#' +#' # OPTIONAL: Display results +#' ee_stars_01 <- ee$Image(assetId) +#' Map$centerObject(ee_stars_01) +#' Map$addLayer(ee_stars_01, list(min = 0, max = 255)) +#' +#' # Method 2 +#' ee_stars_02 <- raster_as_ee( +#' x = x, +#' overwrite = TRUE, +#' assetId = assetId, +#' bucket = "rgee_dev" +#' ) +#' Map$centerObject(ee_stars_02) +#' Map$addLayer(ee_stars_02, list(min = 0, max = 255)) #' } #' @export raster_as_ee <- stars_as_ee diff --git a/R/sf_as_ee.R b/R/sf_as_ee.R index 5ee3beca..f39fc5e8 100755 --- a/R/sf_as_ee.R +++ b/R/sf_as_ee.R @@ -93,27 +93,27 @@ #' print(holePoly$contains(pt)$getInfo() %>% ee_utils_py_to_r()) #' print(evenOddPoly$contains(pt)$getInfo() %>% ee_utils_py_to_r()) #' -#' # # 2. Upload small geometries to EE asset -#' # assetId <- sprintf("%s/%s", ee_get_assethome(), 'toy_poly') -#' # eex <- sf_as_ee( -#' # x = toy_poly, -#' # overwrite = TRUE, -#' # assetId = assetId, -#' # via = "getInfo_to_asset") +#' # 2. Upload small geometries to EE asset +#' assetId <- sprintf("%s/%s", ee_get_assethome(), 'toy_poly') +#' eex <- sf_as_ee( +#' x = toy_poly, +#' overwrite = TRUE, +#' assetId = assetId, +#' via = "getInfo_to_asset") -#' # # 3. Upload large geometries to EE asset -#' # ee_Initialize(gcs = TRUE) +#' # 3. Upload large geometries to EE asset +#' ee_Initialize(gcs = TRUE) -#' # assetId <- sprintf("%s/%s", ee_get_assethome(), 'toy_poly_gcs') -#' # eex <- sf_as_ee( -#' # x = toy_poly, -#' # overwrite = TRUE, -#' # assetId = assetId, -#' # bucket = 'rgee_dev', -#' # monitoring = FALSE, -#' # via = 'gcs_to_asset' -#' # ) -#' # ee_monitoring() +#' assetId <- sprintf("%s/%s", ee_get_assethome(), 'toy_poly_gcs') +#' eex <- sf_as_ee( +#' x = toy_poly, +#' overwrite = TRUE, +#' assetId = assetId, +#' bucket = 'rgee_dev', +#' monitoring = FALSE, +#' via = 'gcs_to_asset' +#' ) +#' ee_monitoring() #' } #' @export sf_as_ee <- function(x, diff --git a/R/utils-download.R b/R/utils-download.R index 2094eff6..f373038d 100755 --- a/R/utils-download.R +++ b/R/utils-download.R @@ -7,7 +7,8 @@ #' @param eeTaskList Logical. If \code{TRUE}, all Earth Engine tasks will be #' listed. #' @param quiet Logical. Suppress info message -#' +#' @return An \code{ee$batch$Task} object with a state "COMPLETED" or "FAILED" +#' according to the response of the Earth Engine server. #' @family helper functions #' @export #' @examples diff --git a/R/utils-upload.R b/R/utils-upload.R index e9ee6737..1a89ef88 100755 --- a/R/utils-upload.R +++ b/R/utils-upload.R @@ -18,8 +18,8 @@ #' ee_Initialize(gcs = TRUE) #' #' # # Define an image. -#' # tif <- system.file("tif/L7_ETMs.tif", package = "stars") -#' # local_to_gcs(x = tif, bucket = 'rgee_dev') +#' tif <- system.file("tif/L7_ETMs.tif", package = "stars") +#' local_to_gcs(x = tif, bucket = 'rgee_dev') #' } #' @export local_to_gcs <- function(x, @@ -116,22 +116,22 @@ local_to_gcs <- function(x, #' shp_dir <- sprintf("%s.shp", tempfile()) #' geozip_dir <- ee_utils_shp_to_zip(x, shp_dir) #' -#' # # 3. From local to gcs -#' # gcs_filename <- local_to_gcs( -#' # x = geozip_dir, -#' # bucket = "rgee_dev" # Insert your own bucket here! -#' # ) -#' # -#' # # 4. Create Table Manifest -#' # manifest <- ee_utils_create_manifest_table( -#' # gs_uri = gcs_filename, -#' # assetId = assetId -#' # ) -#' # -#' # # 5. From GCS to Earth Engine -#' # ee_nc <- gcs_to_ee_table(manifest, overwrite = TRUE) -#' # ee_monitoring() -#' # Map$addLayer(ee$FeatureCollection(ee_nc)) +#' # 3. From local to gcs +#' gcs_filename <- local_to_gcs( +#' x = geozip_dir, +#' bucket = "rgee_dev" # Insert your own bucket here! +#' ) +#' +#' # 4. Create Table Manifest +#' manifest <- ee_utils_create_manifest_table( +#' gs_uri = gcs_filename, +#' assetId = assetId +#' ) +#' +#' # 5. From GCS to Earth Engine +#' ee_nc <- gcs_to_ee_table(manifest, overwrite = TRUE) +#' ee_monitoring() +#' Map$addLayer(ee$FeatureCollection(ee_nc)) #' } #' @export gcs_to_ee_table <- function(manifest, @@ -585,6 +585,7 @@ ee_utils_create_manifest_table <- function(gs_uri, #' Convert EPSG, ESRI or SR-ORG code into a OGC WKT #' #' @param code The projection code. +#' @return A character which represents the same projection in WKT2 string. #' @examples #' \dontrun{ #' library(rgee) diff --git a/inst/WORDLIST b/inst/WORDLIST index 551d125c..89097cb2 100755 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -281,4 +281,4 @@ ee_imagecollection_to_local fileNamePrefix fileFormat SRTM -numpy \ No newline at end of file +numpy diff --git a/man/Map.Rd b/man/Map.Rd index a4336251..9186cc1a 100644 --- a/man/Map.Rd +++ b/man/Map.Rd @@ -159,17 +159,7 @@ m4 <- Map$addLayer( name = "SF" ) -# Case 5: mapview + EarthEnginemap -# library(mapview) -# library(sf) -# nc <- st_read(system.file("shp/arequipa.shp", package="rgee")) -# mapview(nc, m2) - -# Case 6: mapedit -# library(mapedit) -# my_geometry <- m4 \%>\% editMap() - -# Case 7: ImageCollection +# Case 5: ImageCollection nc <- st_read(system.file("shape/nc.shp", package = "sf")) \%>\% st_transform(4326) \%>\% sf_as_ee() @@ -182,7 +172,7 @@ Map$centerObject(nc$geometry()) m5 <- Map$addLayers(ee_s2, legend = TRUE) m5 -# Case 8: Map comparison +# Case 6: Map comparison image <- ee$Image("LANDSAT/LC08/C01/T1/LC08_044034_20140318") Map$centerObject(image) m_ndvi <- Map$addLayer( @@ -194,7 +184,7 @@ m_ndvi <- Map$addLayer( m6 <- m4 | m_ndvi m6 -# Case 9: digging up the metadata +# Case 7: digging up the metadata m6$rgee$tokens m5$rgee$tokens } diff --git a/man/ee_Initialize.Rd b/man/ee_Initialize.Rd index 8cf3a3e0..edd05b07 100644 --- a/man/ee_Initialize.Rd +++ b/man/ee_Initialize.Rd @@ -27,6 +27,9 @@ credential will be cached in the path \code{~/.config/earthengine/}.} \item{quiet}{Logical. Suppress info messages.} } +\value{ +No return value, called for initializing the earthengine-api. +} \description{ Authorize rgee to manage Earth Engine resources, Google Drive, and Google Cloud Storage. The \code{ee_initialize()} via @@ -50,14 +53,6 @@ library(rgee) # Simple init - Load just the Earth Engine credential ee_Initialize() - -# Advanced init - Load full credentials -# ee_Initialize( -# email = "your_email@gmail.com", -# drive = TRUE, -# gcs = TRUE -# ) - ee_user_info() } } diff --git a/man/ee_as_raster.Rd b/man/ee_as_raster.Rd index 680173e4..999644b6 100644 --- a/man/ee_as_raster.Rd +++ b/man/ee_as_raster.Rd @@ -155,30 +155,30 @@ img_02 <- ee_as_raster( img_02_result <- img_02 \%>\% ee_utils_future_value() img_02_result@history$metadata # metadata -# ## gcs - Method 02 -# # Simple -# img_03 <- ee_as_raster( -# image = img, -# region = geometry, -# container = "rgee_dev", -# via = "gcs" -# ) -# -# # Lazy -# img_03 <- ee_as_raster( -# image = img, -# region = geometry, -# container = "rgee_dev", -# lazy = TRUE, -# via = "gcs" -# ) -# -# img_03_result <- img_03 \%>\% ee_utils_future_value() -# img_03_result@history$metadata # metadata +## gcs - Method 02 +# Simple +img_03 <- ee_as_raster( + image = img, + region = geometry, + container = "rgee_dev", + via = "gcs" +) + +# Lazy +img_03 <- ee_as_raster( + image = img, + region = geometry, + container = "rgee_dev", + lazy = TRUE, + via = "gcs" +) + +img_03_result <- img_03 \%>\% ee_utils_future_value() +img_03_result@history$metadata # metadata # OPTIONAL: clean containers -# ee_clean_container(name = "rgee_backup", type = "drive") -# ee_clean_container(name = "rgee_dev", type = "gcs") +ee_clean_container(name = "rgee_backup", type = "drive") +ee_clean_container(name = "rgee_dev", type = "gcs") } } \seealso{ diff --git a/man/ee_as_sf.Rd b/man/ee_as_sf.Rd index b48783b2..072c4f04 100644 --- a/man/ee_as_sf.Rd +++ b/man/ee_as_sf.Rd @@ -158,11 +158,11 @@ sf_randomPoints_drive <- ee_as_sf( ) # Download via GCS -# sf_randomPoints_gcs <- ee_as_sf( -# x = subset, -# via = 'gcs', -# container = 'rgee_dev' #GCS bucket name -# ) +sf_randomPoints_gcs <- ee_as_sf( + x = subset, + via = 'gcs', + container = 'rgee_dev' #GCS bucket name +) } } \concept{vector download functions} diff --git a/man/ee_as_stars.Rd b/man/ee_as_stars.Rd index f7bf9767..7e523b2b 100644 --- a/man/ee_as_stars.Rd +++ b/man/ee_as_stars.Rd @@ -155,31 +155,30 @@ img_02 <- ee_as_stars( img_02_result <- img_02 \%>\% ee_utils_future_value() attr(img_02_result, "metadata") # metadata -# ## gcs - Method 02 -# # Simple -# img_03 <- ee_as_stars( -# image = img, -# region = geometry, -# container = "rgee_dev", -# via = "gcs" -# ) -# -# # Lazy -# img_03 <- ee_as_stars( -# image = img, -# region = geometry, -# container = "rgee_dev", -# lazy = TRUE, -# via = "gcs" -# ) -# -# img_03_result <- img_03 \%>\% ee_utils_future_value() -# attr(img_03_result, "metadata") # metadata -# -# -# # OPTIONAL: clean containers -# ee_clean_container(name = "rgee_backup", type = "drive") -# ee_clean_container(name = "rgee_dev", type = "gcs") +## gcs - Method 02 +# Simple +img_03 <- ee_as_stars( + image = img, + region = geometry, + container = "rgee_dev", + via = "gcs" +) + +# Lazy +img_03 <- ee_as_stars( + image = img, + region = geometry, + container = "rgee_dev", + lazy = TRUE, + via = "gcs" +) + +img_03_result <- img_03 \%>\% ee_utils_future_value() +attr(img_03_result, "metadata") # metadata + +# OPTIONAL: clean containers +ee_clean_container(name = "rgee_backup", type = "drive") +ee_clean_container(name = "rgee_dev", type = "gcs") } } \seealso{ diff --git a/man/ee_check-tools.Rd b/man/ee_check-tools.Rd index ab46ed37..c2699860 100644 --- a/man/ee_check-tools.Rd +++ b/man/ee_check-tools.Rd @@ -22,6 +22,9 @@ ee_check will skip the check of credentials.} \item{quiet}{Logical. Suppress info message} } +\value{ +No return value, called for checking non-R rgee dependencies. +} \description{ R functions for checking Google credentials (Google Earth Engine, Google Drive and Google Cloud Storage), Python environment and the diff --git a/man/ee_clean_container.Rd b/man/ee_clean_container.Rd index 7ded6c78..18f2f8df 100644 --- a/man/ee_clean_container.Rd +++ b/man/ee_clean_container.Rd @@ -15,6 +15,9 @@ and 'gcs' are supported.} \item{quiet}{logical. Suppress info message} } +\value{ +No return value, called for cleaning Google Drive or Google Cloud Storage container. +} \description{ Delete all files from a folder (Google Drive) or a bucket (Google Cloud Storage). Caution: This will permanently delete diff --git a/man/ee_clean_credentials.Rd b/man/ee_clean_credentials.Rd index a91a8b28..0e754f71 100644 --- a/man/ee_clean_credentials.Rd +++ b/man/ee_clean_credentials.Rd @@ -11,21 +11,16 @@ ee_clean_credentials(email = "not_defined", quiet = FALSE) \item{quiet}{Logical. Suppress info messages.} } +\value{ +No return value, called for cleaning Google Drive, Google Cloud Storage, +and/or Earth Engine credentials. +} \description{ Delete all the credentials according to a specific user. The credentials (Google Earth Engine, Google Drive and Google Cloud Storage) are created after running successfully \code{ee_Initialize(...)}. They are saved in the path \code{rgee::ee_get_earthengine_path()}. } -\examples{ -\dontrun{ -library(rgee) - -# ee_clean_credentials() -# ee_clean_credentials('data.colec.fbf@gmail.com') - -} -} \seealso{ Other ee_clean functions: \code{\link{ee_clean_container}()}, diff --git a/man/ee_clean_pyenv.Rd b/man/ee_clean_pyenv.Rd index d71c205d..a58021e7 100644 --- a/man/ee_clean_pyenv.Rd +++ b/man/ee_clean_pyenv.Rd @@ -6,15 +6,12 @@ \usage{ ee_clean_pyenv() } +\value{ +No return value, called for cleaning environmental variables in their system. +} \description{ Remove rgee system variables from .Renviron } -\examples{ -\dontrun{ -# library(rgee) -# ee_clean_pyenv() -} -} \seealso{ Other ee_clean functions: \code{\link{ee_clean_container}()}, diff --git a/man/ee_gcs_to_local.Rd b/man/ee_gcs_to_local.Rd index c9b7f1bc..c98e4c06 100644 --- a/man/ee_gcs_to_local.Rd +++ b/man/ee_gcs_to_local.Rd @@ -86,20 +86,20 @@ mean_l5 <- ic_l5$mean()$rename("NDVI") mean_l5 <- mean_l5$reproject(crs = "EPSG:4326", scale = 500) mean_l5_Amarakaeri <- mean_l5$clip(ee_ROI) -## Move results from Earth Engine to Drive -# task_img <- ee_image_to_gcs( -# image = mean_l5_Amarakaeri, -# bucket = "rgee_dev", -# fileFormat = "GEO_TIFF", -# region = ee_ROI, -# fileNamePrefix = "my_image_demo" -#) +# Move results from Earth Engine to Drive +task_img <- ee_image_to_gcs( + image = mean_l5_Amarakaeri, + bucket = "rgee_dev", + fileFormat = "GEO_TIFF", + region = ee_ROI, + fileNamePrefix = "my_image_demo" +) -# task_img$start() -# ee_monitoring(task_img) +task_img$start() +ee_monitoring(task_img) -## Move results from Drive to local -# img <- ee_gcs_to_local(task = task_img) +# Move results from Drive to local +img <- ee_gcs_to_local(task = task_img) } } \seealso{ diff --git a/man/ee_help.Rd b/man/ee_help.Rd index 9e57ea78..1a52959d 100644 --- a/man/ee_help.Rd +++ b/man/ee_help.Rd @@ -11,6 +11,9 @@ ee_help(eeobject, browser = FALSE) \item{browser}{Logical. Display documentation in the browser.} } +\value{ +No return value, called for displaying Earth Engine documentation. +} \description{ Documentation for Earth Engine Objects } diff --git a/man/ee_image_to_gcs.Rd b/man/ee_image_to_gcs.Rd index 9c23e26a..ca78eeb3 100644 --- a/man/ee_image_to_gcs.Rd +++ b/man/ee_image_to_gcs.Rd @@ -134,20 +134,20 @@ mean_l5 <- mean_l5$reproject(crs = "EPSG:4326", scale = 500) mean_l5_Amarakaeri <- mean_l5$clip(ee_ROI) # Move results from Earth Engine to GCS -# task_img <- ee_image_to_gcs( -# image = mean_l5_Amarakaeri, -# bucket = "rgee_dev", -# fileFormat = "GEO_TIFF", -# region = ee_ROI, -# fileNamePrefix = "my_image_demo" -# ) -# -# task_img$start() -# ee_monitoring(task_img) +task_img <- ee_image_to_gcs( + image = mean_l5_Amarakaeri, + bucket = "rgee_dev", + fileFormat = "GEO_TIFF", + region = ee_ROI, + fileNamePrefix = "my_image_demo" +) + +task_img$start() +ee_monitoring(task_img) # Move results from GCS to local -# ee_gcs_to_local(task = task_img) -# plot(img) +ee_gcs_to_local(task = task_img) + } } \seealso{ diff --git a/man/ee_install.Rd b/man/ee_install.Rd index 76d08d3d..2a01e3c4 100644 --- a/man/ee_install.Rd +++ b/man/ee_install.Rd @@ -19,6 +19,9 @@ to install. By default \code{rgee::ee_version()}.} \item{confirm}{Logical. Confirm before restarting R?.} } +\value{ +No return value, called for installing non-R dependencies. +} \description{ Create an isolated Python virtual environment with all rgee dependencies. \code{ee_install} realize the following six (6) tasks: @@ -40,12 +43,6 @@ for further details. changes.} } } -\examples{ -\dontrun{ -# library(rgee) -# ee_install() #It is just necessary once -} -} \seealso{ Other ee_install functions: \code{\link{ee_install_set_pyenv}()}, diff --git a/man/ee_install_set_pyenv.Rd b/man/ee_install_set_pyenv.Rd index 45843d27..3ab8f288 100644 --- a/man/ee_install_set_pyenv.Rd +++ b/man/ee_install_set_pyenv.Rd @@ -13,6 +13,9 @@ ee_install_set_pyenv(py_path = NULL, py_env = NULL, quiet = FALSE) \item{quiet}{Logical. Suppress info message} } +\value{ +no return value, called for setting EARTHENGINE_PYTHON in .Renviron +} \description{ This function create a new environment variable called 'EARTHENGINE_PYTHON'. It is used to set the Python environment to be used by rgee. diff --git a/man/ee_install_upgrade.Rd b/man/ee_install_upgrade.Rd index 6bdb6a45..8bf672df 100644 --- a/man/ee_install_upgrade.Rd +++ b/man/ee_install_upgrade.Rd @@ -16,6 +16,9 @@ By default \code{rgee::ee_version()}.} \item{earthengine_env}{Character. The name, or full path, of the environment in which the earthengine-api packages are to be installed.} } +\value{ +no return value, called to upgrade the earthengine-api Python package +} \description{ Upgrade the Earth Engine Python API } diff --git a/man/ee_monitoring.Rd b/man/ee_monitoring.Rd index 4e52c095..b4bb714c 100644 --- a/man/ee_monitoring.Rd +++ b/man/ee_monitoring.Rd @@ -18,6 +18,10 @@ listed.} \item{quiet}{Logical. Suppress info message} } +\value{ +An \code{ee$batch$Task} object with a state "COMPLETED" or "FAILED" +according to the response of the Earth Engine server. +} \description{ Monitoring Earth Engine task progress } diff --git a/man/ee_search-tools.Rd b/man/ee_search-tools.Rd deleted file mode 100644 index 2f80b954..00000000 --- a/man/ee_search-tools.Rd +++ /dev/null @@ -1,88 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/Deprecated.R -\name{ee_search-tools} -\alias{ee_search-tools} -\alias{ee_search_dataset} -\alias{ee_search_startdate} -\alias{ee_search_enddate} -\alias{ee_search_type} -\alias{ee_search_provider} -\alias{ee_search_provider_list} -\alias{ee_search_tags} -\alias{ee_search_title} -\alias{ee_search_tagstitle} -\alias{ee_search_title_list} -\alias{ee_search_display} -\title{Interface to search into the Earth Engine Data Catalog} -\usage{ -ee_search_dataset(quiet = FALSE, upgrade = FALSE, path_dataset = NULL) - -ee_search_startdate(ee_search_dataset, stardate) - -ee_search_enddate(ee_search_dataset, enddate = Sys.Date()) - -ee_search_type(ee_search_dataset, type) - -ee_search_provider(ee_search_dataset, provider) - -ee_search_provider_list(ee_search_dataset) - -ee_search_tags(ee_search_dataset, ..., logical_operator = "OR") - -ee_search_title(ee_search_dataset, ..., logical_operator = "OR") - -ee_search_tagstitle(ee_search_dataset, ..., logical_operator = "OR") - -ee_search_title_list(ee_search_dataset) - -ee_search_display(ee_search_dataset, maxdisplay = 10) -} -\arguments{ -\item{quiet}{logical. Suppress info message} - -\item{upgrade}{Logical. If the dataset needs to be upgraded.} - -\item{path_dataset}{Path of the dataset. By default it will loaded -automatically.} - -\item{ee_search_dataset}{data.frame generated by rgee::ee_search_Datasets() -or a character which represents the EE dataset ID.} - -\item{stardate}{Character. Start date of dataset availability.} - -\item{enddate}{Character. End date of dataset availability.} - -\item{type}{Character. "Image", "ImageCollection" or a "table".} - -\item{provider}{Character. Name of the dataset's provider. See -ee_search_provider_list()} - -\item{...}{Character vector. tags} - -\item{logical_operator}{Character. Available just for rgee::ee_search_tags -and rgee::ee_search_title. 'AND' represents inclusiveness between tags in -searching and 'OR' exclusiveness.} - -\item{maxdisplay}{Numeric. Maximum number of tabs to display in their browser} -} -\value{ -A data.frame where rows represents public data archive. -} -\description{ -R functions for searching in Earth Engine's public data archive. -} -\examples{ -\dontrun{ -library(rgee) -ee_Initialize() - -# ee_search_provider_list() -# ee_search_title_list() -myquery <- ee_search_dataset() \%>\% - ee_search_type("Image") \%>\% - ee_search_provider("WWF") \%>\% - ee_search_tags("srtm", "flow", "direction", "dem") \%>\% - ee_search_title("15", "Flow", logical_operator = "AND") \%>\% - ee_search_display() -} -} diff --git a/man/ee_table_to_gcs.Rd b/man/ee_table_to_gcs.Rd index b4c99df5..b84203a4 100644 --- a/man/ee_table_to_gcs.Rd +++ b/man/ee_table_to_gcs.Rd @@ -70,16 +70,16 @@ amk_fc <- ee$FeatureCollection( list(ee$Feature(ee_ROI, list(name = "Amarakaeri"))) ) -#task_vector <- ee_table_to_gcs( -# collection = amk_fc, -# bucket = "rgee_dev", -# fileFormat = "SHP", -# fileNamePrefix = "geom_Amarakaeri" -#) -#task_vector$start() -#ee_monitoring(task_vector) # optional -#amk_geom <- ee_gcs_to_local(task = task_vector) -#plot(sf::read_sf(amk_geom[3]), border = "red", lwd = 10) +task_vector <- ee_table_to_gcs( + collection = amk_fc, + bucket = "rgee_dev", + fileFormat = "SHP", + fileNamePrefix = "geom_Amarakaeri" +) +task_vector$start() +ee_monitoring(task_vector) # optional +amk_geom <- ee_gcs_to_local(task = task_vector) +plot(sf::read_sf(amk_geom[3]), border = "red", lwd = 10) } } \seealso{ diff --git a/man/ee_user_info.Rd b/man/ee_user_info.Rd index 8b7e02f8..22e6939e 100644 --- a/man/ee_user_info.Rd +++ b/man/ee_user_info.Rd @@ -9,6 +9,9 @@ ee_user_info(quiet = FALSE) \arguments{ \item{quiet}{Logical. Suppress info messages.} } +\value{ +A list with information about the Earth Engine user. +} \description{ Display the credentials and general info of the initialized user } diff --git a/man/ee_utils_get_crs.Rd b/man/ee_utils_get_crs.Rd index fd2d927d..006f9891 100644 --- a/man/ee_utils_get_crs.Rd +++ b/man/ee_utils_get_crs.Rd @@ -9,6 +9,9 @@ ee_utils_get_crs(code) \arguments{ \item{code}{The projection code.} } +\value{ +A character which represents the same projection in WKT2 string. +} \description{ Convert EPSG, ESRI or SR-ORG code into a OGC WKT } diff --git a/man/ee_utils_gif_annotate.Rd b/man/ee_utils_gif_annotate.Rd index a1fde11b..c9691e25 100644 --- a/man/ee_utils_gif_annotate.Rd +++ b/man/ee_utils_gif_annotate.Rd @@ -111,8 +111,8 @@ animation \%>\% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt -animation_wtxt -# ee_utils_gif_save(animation_wtxt, path = "raster_as_ee.gif") +gc(reset = TRUE) +ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) } } \seealso{ diff --git a/man/ee_utils_gif_creator.Rd b/man/ee_utils_gif_creator.Rd index 19cb03ae..f4e5f3f8 100644 --- a/man/ee_utils_gif_creator.Rd +++ b/man/ee_utils_gif_creator.Rd @@ -95,8 +95,8 @@ animation \%>\% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt -animation_wtxt -# ee_utils_gif_save(animation_wtxt, path = "raster_as_ee.gif") +gc(reset = TRUE) +ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) } } \seealso{ diff --git a/man/ee_utils_gif_save.Rd b/man/ee_utils_gif_save.Rd index fbf5e0e6..0589ce8b 100644 --- a/man/ee_utils_gif_save.Rd +++ b/man/ee_utils_gif_save.Rd @@ -33,6 +33,9 @@ ee_utils_gif_save( \item{flatten}{should image be flattened before writing? This also replaces transparency with background color.} } +\value{ +No return value, called to write a GIF file. +} \description{ Write a magick-image object as a GIF file using magick package. This function is a wrapper around \link[magick:editing]{image_write}. @@ -86,8 +89,8 @@ animation \%>\% ee_utils_gif_annotate("created using {magick} + {rgee}", size = 15, font = "sans",location = "+70+20") -> animation_wtxt -animation_wtxt -# ee_utils_gif_save(animation_wtxt, path = "raster_as_ee.gif") +gc(reset = TRUE) +ee_utils_gif_save(animation_wtxt, path = paste0(tempfile(), ".gif")) } } \seealso{ diff --git a/man/ee_utils_search_display.Rd b/man/ee_utils_search_display.Rd index ce67103f..8e970bd0 100644 --- a/man/ee_utils_search_display.Rd +++ b/man/ee_utils_search_display.Rd @@ -9,6 +9,9 @@ ee_utils_search_display(ee_search_dataset) \arguments{ \item{ee_search_dataset}{character which represents the EE dataset ID.} } +\value{ +No return value, called for displaying the Earth Engine dataset in the browser. +} \description{ Search into the Earth Engine Data Catalog } diff --git a/man/gcs_to_ee_table.Rd b/man/gcs_to_ee_table.Rd index 1c48b39f..72dc6c34 100644 --- a/man/gcs_to_ee_table.Rd +++ b/man/gcs_to_ee_table.Rd @@ -43,21 +43,21 @@ assetId <- sprintf("\%s/\%s", ee_get_assethome(), 'toy_poly_gcs') shp_dir <- sprintf("\%s.shp", tempfile()) geozip_dir <- ee_utils_shp_to_zip(x, shp_dir) -# # 3. From local to gcs -# gcs_filename <- local_to_gcs( -# x = geozip_dir, -# bucket = "rgee_dev" # Insert your own bucket here! -# ) -# -# # 4. Create Table Manifest -# manifest <- ee_utils_create_manifest_table( -# gs_uri = gcs_filename, -# assetId = assetId -# ) -# -# # 5. From GCS to Earth Engine -# ee_nc <- gcs_to_ee_table(manifest, overwrite = TRUE) -# ee_monitoring() -# Map$addLayer(ee$FeatureCollection(ee_nc)) +# 3. From local to gcs +gcs_filename <- local_to_gcs( + x = geozip_dir, + bucket = "rgee_dev" # Insert your own bucket here! +) + +# 4. Create Table Manifest +manifest <- ee_utils_create_manifest_table( + gs_uri = gcs_filename, + assetId = assetId +) + +# 5. From GCS to Earth Engine +ee_nc <- gcs_to_ee_table(manifest, overwrite = TRUE) +ee_monitoring() +Map$addLayer(ee$FeatureCollection(ee_nc)) } } diff --git a/man/local_to_gcs.Rd b/man/local_to_gcs.Rd index 75eb9abb..dce143fe 100644 --- a/man/local_to_gcs.Rd +++ b/man/local_to_gcs.Rd @@ -30,8 +30,8 @@ library(stars) ee_Initialize(gcs = TRUE) # # Define an image. -# tif <- system.file("tif/L7_ETMs.tif", package = "stars") -# local_to_gcs(x = tif, bucket = 'rgee_dev') +tif <- system.file("tif/L7_ETMs.tif", package = "stars") +local_to_gcs(x = tif, bucket = 'rgee_dev') } } \seealso{ diff --git a/man/print.ee.computedobject.ComputedObject.Rd b/man/print.ee.computedobject.ComputedObject.Rd index b64ee586..140d496d 100644 --- a/man/print.ee.computedobject.ComputedObject.Rd +++ b/man/print.ee.computedobject.ComputedObject.Rd @@ -14,6 +14,9 @@ \item{type}{Character. What to show about the x object?. Three options are supported: "json", "simply", "ee_print". By default "simply".} } +\value{ +No return value, called for displaying Earth Engine objects. +} \description{ print Earth Engine object } diff --git a/man/raster_as_ee.Rd b/man/raster_as_ee.Rd index 8abb08ba..07506468 100644 --- a/man/raster_as_ee.Rd +++ b/man/raster_as_ee.Rd @@ -54,36 +54,36 @@ tif <- system.file("tif/L7_ETMs.tif", package = "stars") x <- stack(tif) assetId <- sprintf("\%s/\%s",ee_get_assethome(),'raster_l7') -# # Method 1 -# # 1. Move from local to gcs -# gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') -# -# # 2. Create a manifest -# manifest <- ee_utils_create_manifest_image(gs_uri, assetId) -# -# # 3. Pass from gcs to asset -# gcs_to_ee_image( -# manifest = manifest, -# overwrite = TRUE -# ) -# -# # OPTIONAL: Monitoring progress -# ee_monitoring() -# -# # OPTIONAL: Display results -# ee_stars_01 <- ee$Image(assetId) -# Map$centerObject(ee_stars_01) -# Map$addLayer(ee_stars_02, list(min = 0, max = 255)) -# -# # Method 2 -# ee_stars_02 <- raster_as_ee( -# x = x, -# overwrite = TRUE, -# assetId = assetId, -# bucket = "rgee_dev" -# ) -# Map$centerObject(ee_stars_02) -# Map$addLayer(ee_stars_02, list(min = 0, max = 255)) +# Method 1 +# 1. Move from local to gcs +gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') + +# 2. Create a manifest +manifest <- ee_utils_create_manifest_image(gs_uri, assetId) + +# 3. Pass from gcs to asset +gcs_to_ee_image( + manifest = manifest, + overwrite = TRUE +) + +# OPTIONAL: Monitoring progress +ee_monitoring() + +# OPTIONAL: Display results +ee_stars_01 <- ee$Image(assetId) +Map$centerObject(ee_stars_01) +Map$addLayer(ee_stars_01, list(min = 0, max = 255)) + +# Method 2 +ee_stars_02 <- raster_as_ee( + x = x, + overwrite = TRUE, + assetId = assetId, + bucket = "rgee_dev" +) +Map$centerObject(ee_stars_02) +Map$addLayer(ee_stars_02, list(min = 0, max = 255)) } } \seealso{ diff --git a/man/sf_as_ee.Rd b/man/sf_as_ee.Rd index 6fcfcb21..d27bd2dc 100644 --- a/man/sf_as_ee.Rd +++ b/man/sf_as_ee.Rd @@ -125,24 +125,24 @@ pt <- ee$Geometry$Point(c(1.5, 1.5)) print(holePoly$contains(pt)$getInfo() \%>\% ee_utils_py_to_r()) print(evenOddPoly$contains(pt)$getInfo() \%>\% ee_utils_py_to_r()) -# # 2. Upload small geometries to EE asset -# assetId <- sprintf("\%s/\%s", ee_get_assethome(), 'toy_poly') -# eex <- sf_as_ee( -# x = toy_poly, -# overwrite = TRUE, -# assetId = assetId, -# via = "getInfo_to_asset") -# # 3. Upload large geometries to EE asset -# ee_Initialize(gcs = TRUE) -# assetId <- sprintf("\%s/\%s", ee_get_assethome(), 'toy_poly_gcs') -# eex <- sf_as_ee( -# x = toy_poly, -# overwrite = TRUE, -# assetId = assetId, -# bucket = 'rgee_dev', -# monitoring = FALSE, -# via = 'gcs_to_asset' -# ) -# ee_monitoring() +# 2. Upload small geometries to EE asset +assetId <- sprintf("\%s/\%s", ee_get_assethome(), 'toy_poly') +eex <- sf_as_ee( + x = toy_poly, + overwrite = TRUE, + assetId = assetId, + via = "getInfo_to_asset") +# 3. Upload large geometries to EE asset +ee_Initialize(gcs = TRUE) +assetId <- sprintf("\%s/\%s", ee_get_assethome(), 'toy_poly_gcs') +eex <- sf_as_ee( + x = toy_poly, + overwrite = TRUE, + assetId = assetId, + bucket = 'rgee_dev', + monitoring = FALSE, + via = 'gcs_to_asset' +) +ee_monitoring() } } diff --git a/man/stars_as_ee.Rd b/man/stars_as_ee.Rd index b4837051..3127c31e 100644 --- a/man/stars_as_ee.Rd +++ b/man/stars_as_ee.Rd @@ -51,36 +51,36 @@ tif <- system.file("tif/L7_ETMs.tif", package = "stars") x <- read_stars(tif) assetId <- sprintf("\%s/\%s",ee_get_assethome(),'stars_l7') -# # # Method 1 -# # 1. Move from local to gcs -# gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') +# # Method 1 +# 1. Move from local to gcs +gs_uri <- local_to_gcs(x = tif, bucket = 'rgee_dev') -# # 2. Create a manifest -# manifest <- ee_utils_create_manifest_image(gs_uri, assetId) +# 2. Create a manifest +manifest <- ee_utils_create_manifest_image(gs_uri, assetId) -# # 3. Pass from gcs to asset -# gcs_to_ee_image( -# manifest = manifest, -# overwrite = TRUE -# ) +# 3. Pass from gcs to asset +gcs_to_ee_image( + manifest = manifest, + overwrite = TRUE +) + +# OPTIONAL: Monitoring progress +ee_monitoring() -# # OPTIONAL: Monitoring progress -# ee_monitoring() -# -# # OPTIONAL: Display results -# ee_stars_01 <- ee$Image(assetId) -# Map$centerObject(ee_stars_01) -# Map$addLayer(ee_stars_01, list(min = 0, max = 255)) -# -# # Method 2 -# ee_stars_02 <- stars_as_ee( -# x = x, -# overwrite = TRUE, -# assetId = assetId, -# bucket = "rgee_dev" -# ) -# Map$centerObject(ee_stars_02) -# Map$addLayer(ee_stars_02, list(min = 0, max = 255)) +# OPTIONAL: Display results +ee_stars_01 <- ee$Image(assetId) +Map$centerObject(ee_stars_01) +Map$addLayer(ee_stars_01, list(min = 0, max = 255)) + +# Method 2 +ee_stars_02 <- stars_as_ee( + x = x, + overwrite = TRUE, + assetId = assetId, + bucket = "rgee_dev" +) +Map$centerObject(ee_stars_02) +Map$addLayer(ee_stars_02, list(min = 0, max = 255)) } } \seealso{ diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 19843874..2c7b2d0a 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -155,16 +155,3 @@ reference: - ee_utils_gif_save - ee_utils_future_value - ee_utils_search_display - - - title: "Search dataset" - contents: - - ee_search_dataset - - ee_search_startdate - - ee_search_enddate - - ee_search_type - - ee_search_provider - - ee_search_provider_list - - ee_search_tags - - ee_search_title - - ee_search_tagstitle - - ee_search_title_list diff --git a/tests/testthat/test-Initialize.R b/tests/testthat/test-Initialize.R index 966b5bb1..227d9f2e 100755 --- a/tests/testthat/test-Initialize.R +++ b/tests/testthat/test-Initialize.R @@ -43,5 +43,5 @@ test_that("ee_users",{ test_that("ee_users",{ counts <- ee_user_info() - expect_true(counts) + expect_type(counts, "list") }) diff --git a/tests/testthat/test-check.R b/tests/testthat/test-check.R index a8076a8c..2a1f6543 100755 --- a/tests/testthat/test-check.R +++ b/tests/testthat/test-check.R @@ -9,6 +9,6 @@ test_that("simple ee_check ",{ }) test_that("ee_check ",{ - expect_null(ee_check()) + expect_true(ee_check()) })