r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
677 stars 146 forks source link

ee_as_raster() error #272

Closed MelanieDickie closed 2 years ago

MelanieDickie commented 2 years ago

At submit an issue, please attached the following information of your rgee session:

library(rgee)

# Initialize the Earth Engine module.
ee_Initialize()

# Print metadata for a DEM dataset.
print(ee$Image('USGS/SRTMGL1_003')$getInfo())

Attach your Python (reticulate) configuration:

library(reticulate)
py_config()

> reticulate::py_config()
python:         C:/Users/Patricia/AppData/Local/r-miniconda/envs/rgee/python.exe
libpython:      C:/Users/Patricia/AppData/Local/r-miniconda/envs/rgee/python38.dll
pythonhome:     C:/Users/Patricia/AppData/Local/r-miniconda/envs/rgee
version:        3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:00) [MSC v.1929 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/Patricia/AppData/Local/r-miniconda/envs/rgee/Lib/site-packages/numpy
numpy_version:  1.23.0
ee:             C:\Users\Patricia\AppData\Local\R-MINI~1\envs\rgee\lib\site-packages\ee\__init__.p

NOTE: Python version was forced by RETICULATE_PYTHON

Description

I'm trying to save an ee.image to a raster via drive. I've done this successfully in the past with the code below. However, I am now running into an authentication issue (see https://github.com/r-spatial/rgee/issues/271) which I've been able to bypass using instructions from https://github.com/r-spatial/rgee/issues/267: library(rgee) ee$Authenticate() ee$Initialize()

(though I don't think the workaround is reproducible, and if I were to use ee_Authenticate() I still get an error)

I'm not sure if this issue is tied to my current issue. I am able to bring in ImageCollections and process them, but when I try to move them locally I receive an error (see below). Note that I get the same error if I attempt other ways to move to Local. I provide one example traceback().

What I Did

> Delta2019R <- ee_as_raster(Delta2019, region = roi_big,
+                            dsn = file.path("G:\\My Drive\\CMU\\EcosystemCameras\\Delta2019.tif"),
+                            via = "drive", crs = "SR-ORG:6974",scale = 231.6564)
- region parameters
 sfg      : POLYGON ((-116.9454 53.6322 .... .56494, -116.9454 53.63221)) 
 CRS      : GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563, ..... 
 geodesic : FALSE 
 evenOdd  : TRUE 

- download parameters (Google Drive)
 Image ID    : Delta2019 
 Google user : mvezina@ualberta.ca 
 Folder name : rgee_backup 
 Date        : 2022_07_08_11_01_33 
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 0s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 5s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 10s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 15s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 20s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 25s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 30s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 35s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 40s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 45s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 50s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 55s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 60s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 65s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 70s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 75s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 80s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 85s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 90s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 95s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 100s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 105s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 110s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 115s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 120s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 125s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 130s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 135s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 140s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 145s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 150s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 155s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 160s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 165s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 170s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 175s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 180s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 185s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 190s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 195s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 200s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 205s>.
Polling for task <id: 2R2BPTD2H3CTOOPI3EACB6IM, time: 210s>.
State: COMPLETED
Moving image from Google Drive to Local ... Please wait  
Error: 'with_drive_quiet' is not an exported object from 'namespace:googledrive'

> task_img <- ee_image_to_drive(
+   image = Delta2019,
+   fileFormat = "GEO_TIFF",
+   region = roi_big,
+   fileNamePrefix = "EVI2019"
+ )
> task_img$start()
> ee_monitoring(task_img)
Polling for task <id: IJBCGYVEZ3IBS7R2AKKP2GT5, time: 0s>.
Polling for task <id: IJBCGYVEZ3IBS7R2AKKP2GT5, time: 5s>.
State: COMPLETED
> ee_drive_to_local(task = task_img)
Error: 'with_drive_quiet' is not an exported object from 'namespace:googledrive'

> traceback()
4: stop(gettextf("'%s' is not an exported object from 'namespace:%s'", 
       name, getNamespaceName(ns)), call. = FALSE, domain = NA)
3: getExportedValue(pkg, name)
2: googledrive::with_drive_quiet
1: ee_drive_to_local(task = task_img)
csaybar commented 2 years ago

Hi @MelanieDickie It seems you are using an old version of the R googledrive package. Can you try upgrading the package? :eyes:

MelanieDickie commented 2 years ago

Thanks @csaybar. I updated all my packages, here is google drive:

packageVersion("googledrive") [1] ‘2.0.0’

I'm still getting errors. I did some crazy combination of suggested fixes in various posted Issues over the course of two days, and somehow it worked - but only temporarily. It's again not working. And I can not reproduce the combination of steps that got me there. Something along the lines of redownloading rgee from git (not CRAN via remotes::install_github("r-spatial/rgee"), updating my Python API, installing gcloud, changing settings in my google account, and using the work-around from #267 (ee$Authenticate()ee$Initialize()).

What I've tried this morning: -update all packages -library(rgee) fails, despite having previously installed it. So I re-try: remotes::install_github("r-spatial/rgee") library(rgee)

library(rgee) Error: package or namespace load failed for ‘rgee’: .onLoad failed in loadNamespace() for 'rgee', details: call: py_module_import(module, convert = convert) error: ModuleNotFoundError: No module named 'ee'

csaybar commented 2 years ago

Are you using Rstudio? Can you see if this issue also happens in R-base?

Please share with us the next information.

library(rgee)
reticulate::import("ee")$`__version__`

sessionInfo()
MelanieDickie commented 2 years ago

I am, but the problem persists in base R:

library(rgee) reticulate::import("ee")$__version__ Error in py_module_import(module, convert = convert) : ModuleNotFoundError: No module named 'ee' In addition: Warning message: In readLines(rf) : incomplete final line found on 'C:\Users\Patricia\AppData\Local\Temp\Rtmpm6Z0Qa\file1f242a0c967'

sessionInfo() R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19043)

Matrix products: default

locale: [1] LC_COLLATE=English_Canada.1252 LC_CTYPE=English_Canada.1252
[3] LC_MONETARY=English_Canada.1252 LC_NUMERIC=C
[5] LC_TIME=English_Canada.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] rgee_1.1.4

loaded via a namespace (and not attached): [1] Rcpp_1.0.8.3 here_1.0.1 lattice_0.20-41 png_0.1-7
[5] ps_1.6.0 rprojroot_2.0.3 digest_0.6.27 crayon_1.5.1
[9] rappdirs_0.3.3 grid_3.6.2 R6_2.5.1 jsonlite_1.7.2
[13] magrittr_2.0.3 rlang_1.0.3 cli_3.3.0 leaflet_2.1.1
[17] Matrix_1.2-18 reticulate_1.25 htmlwidgets_1.5.4 crosstalk_1.2.0
[21] fastmap_1.1.0 compiler_3.6.2 processx_3.5.2 htmltools_0.5.2

csaybar commented 2 years ago

Are you available for a quite short meeting (if yes, please write me an email at csaybar@gmail.com)?. I want to take a deep look at why this sometimes happens in some windows systems :pray:

csaybar commented 2 years ago

See #271