r-spatial / rgee

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

broke rgee and can't figure out why. #348

Open ctlamb opened 1 year ago

ctlamb commented 1 year ago

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

usage: earthengine [-h] [--ee_config EE_CONFIG] [--service_account_file SERVICE_ACCOUNT_FILE] [--project PROJECT_OVERRIDE] {authenticate,acl,asset,cp,create,ls,licenses,du,mv,model,rm,set_project,task,unset_project,upload,upload_manifest,upload_table_manifest} ...

Earth Engine Command Line Interface.

options: -h, --help show this help message and exit --ee_config EE_CONFIG Path to the earthengine configuration file. Defaults to "~/.config/earthengine/credentials". --service_account_file SERVICE_ACCOUNT_FILE Path to a service account credentialsfile. Overrides any ee_config if specified. --project PROJECT_OVERRIDE Specifies a Google Cloud Platform Project id to override the call.

Commands: {authenticate,acl,asset,cp,create,ls,licenses,du,mv,model,rm,set_project,task,unset_project,upload,upload_manifest,upload_table_manifest} authenticate Prompts the user to authorize access to Earth Engine via OAuth2. acl Prints or updates the access control list of the specified asset. asset Prints or updates metadata associated with an Earth Engine asset. cp Creates a new Earth Engine asset as a copy of another asset. create Creates assets and folders. ls Prints the contents of a folder or collection. licenses Prints the name and license of all third party dependencies. du Prints the size and names of all items in a given folder or collection. mv Moves or renames an Earth Engine asset. model TensorFlow model related commands. rm Deletes the specified assets. set_project Sets the default user project to be used for all API calls. task Prints information about or manages long-running tasks. unset_project UnSets the default user project to be used for all API calls. upload Uploads assets to Earth Engine. upload_manifest Uploads an image to Earth Engine using the given manifest file. upload_table_manifest Uploads a table to Earth Engine using the given manifest file. -ne


- [ ] You can find the credentials file on your system: 
```r
library(rgee)
ee_path <- path.expand("~/.config/earthengine/credentials")
file.exists(ee_path)

library(reticulate) library(rgee) ee_path <- path.expand("~/.config/earthengine/credentials") file.exists(ee_path) [1] TRUE

  • [ ] You can run a simple EE command from R:
> library(rgee)
> 
> # Initialize the Earth Engine module.
> ee_Initialize()
── rgee 1.1.5 ────────────────────────────────────────────────────────────────────────────────────────────────────── earthengine-api 0.1.323 ── 
 ✔ user: not_defined
 ✔ Initializing Google Earth Engine:  DONE!
 ✔ Earth Engine account: users/lambecoresearch 
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 
> 
> # Print metadata for a DEM dataset.
> print(ee$Image('USGS/SRTMGL1_003')$getInfo())
$type
[1] "Image"

$bands
$bands[[1]]
$bands[[1]]$id
[1] "elevation"

$bands[[1]]$data_type
$bands[[1]]$data_type$type
[1] "PixelType"

$bands[[1]]$data_type$precision
[1] "int"

$bands[[1]]$data_type$min
[1] -32768

$bands[[1]]$data_type$max
[1] 32767

$bands[[1]]$dimensions
[1] 1296001  417601

$bands[[1]]$crs
[1] "EPSG:4326"

$bands[[1]]$crs_transform
$bands[[1]]$crs_transform[[1]]
[1] 0.0002777778

$bands[[1]]$crs_transform[[2]]
[1] 0

$bands[[1]]$crs_transform[[3]]
[1] -180.0001

$bands[[1]]$crs_transform[[4]]
[1] 0

$bands[[1]]$crs_transform[[5]]
[1] -0.0002777778

$bands[[1]]$crs_transform[[6]]
[1] 60.00014

$id
[1] "USGS/SRTMGL1_003"

$version
[1] -1000009435

$properties
$properties$`system:visualization_0_min`
[1] "0.0"

$properties$type_name
[1] "Image"

$properties$keywords
[1] "dem"         "elevation"   "geophysical" "nasa"        "srtm"        "topography"  "usgs"       

$properties$thumb
[1] "https://mw1.google.com/ges/dd/images/SRTM90_V4_thumb.png"

$properties$description
[1] "<p>The Shuttle Radar Topography Mission (SRTM, see <a href=\"https://onlinelibrary.wiley.com/doi/10.1029/2005RG000183/full\">Farr\net al. 2007</a>)\ndigital elevation data is an international research effort that\nobtained digital elevation models on a near-global scale. This\nSRTM V3 product (SRTM Plus) is provided by NASA JPL\nat a resolution of 1 arc-second (approximately 30m).</p><p>This dataset has undergone a void-filling process using open-source data\n(ASTER GDEM2, GMTED2010, and NED), as opposed to other versions that\ncontain voids or have been void-filled with commercial sources.\nFor more information on the different versions see the\n<a href=\"https://lpdaac.usgs.gov/documents/13/SRTM_Quick_Guide.pdf\">SRTM Quick Guide</a>.</p><p>Documentation:</p><ul><li><p><a href=\"https://lpdaac.usgs.gov/documents/179/SRTM_User_Guide_V3.pdf\">User&#39;s Guide</a></p></li><li><p><a href=\"https://lpdaac.usgs.gov/documents/13/SRTM_Quick_Guide.pdf\">General Documentation</a></p></li><li><p><a href=\"https://doi.org/10.1029/2005RG000183\">Algorithm Theoretical Basis Document (ATBD)</a></p></li></ul><p><b>Provider: <a href=\"https://cmr.earthdata.nasa.gov/search/concepts/C1000000240-LPDAAC_ECS.html\">NASA / USGS / JPL-Caltech</a></b><br><p><b>Bands</b><table class=\"eecat\"><tr><th scope=\"col\">Name</th><th scope=\"col\">Description</th></tr><tr><td>elevation</td><td><p>Elevation</p></td></tr></table><p><b>Terms of Use</b><br><p>Unless otherwise noted, images and video on JPL public\nweb sites (public sites ending with a jpl.nasa.gov address) may\nbe used for any purpose without prior permission. For more information\nand exceptions visit the <a href=\"https://www.jpl.nasa.gov/imagepolicy/\">JPL Image Use Policy site</a>.</p><p><b>Suggested citation(s)</b><ul><li><p>Farr, T.G., Rosen, P.A., Caro, E., Crippen, R., Duren, R., Hensley,\nS., Kobrick, M., Paller, M., Rodriguez, E., Roth, L., Seal, D.,\nShaffer, S., Shimada, J., Umland, J., Werner, M., Oskin, M., Burbank,\nD., and Alsdorf, D.E., 2007, The shuttle radar topography mission:\nReviews of Geophysics, v. 45, no. 2, RG2004, at\n<a href=\"https://doi.org/10.1029/2005RG000183\">https://doi.org/10.1029/2005RG000183</a>.</p></li></ul><style>\n  table.eecat {\n  border: 1px solid black;\n  border-collapse: collapse;\n  font-size: 13px;\n  }\n  table.eecat td, tr, th {\n  text-align: left; vertical-align: top;\n  border: 1px solid gray; padding: 3px;\n  }\n  td.nobreak { white-space: nowrap; }\n</style>"

$properties$source_tags
[1] "nasa" "usgs"

$properties$visualization_0_max
[1] "6000.0"

$properties$title
[1] "NASA SRTM Digital Elevation 30m"

$properties$product_tags
[1] "srtm"        "elevation"   "topography"  "dem"         "geophysical"

$properties$provider
[1] "NASA / USGS / JPL-Caltech"

$properties$visualization_0_min
[1] "0.0"

$properties$visualization_0_name
[1] "Elevation"

$properties$date_range
[1] 1039427584 1989827584

$properties$`system:visualization_0_gamma`
[1] "1.6"

$properties$period
[1] 0

$properties$`system:visualization_0_bands`
[1] "elevation"

$properties$provider_url
[1] "https://cmr.earthdata.nasa.gov/search/concepts/C1000000240-LPDAAC_ECS.html"

$properties$visualization_0_gamma
[1] "1.6"

$properties$sample
[1] "https://mw1.google.com/ges/dd/images/SRTM90_V4_sample.png"

$properties$tags
[1] "dem"         "elevation"   "geophysical" "nasa"        "srtm"        "topography"  "usgs"       

$properties$`system:visualization_0_max`
[1] "6000.0"

$properties$`system:visualization_0_name`
[1] "Elevation"

$properties$`system:asset_size`
[1] -351347924

$properties$visual

Attach your Python (reticulate) configuration:

> py_config()
python:         /Users/claytonlamb/.virtualenvs/rgee/bin/python
libpython:      /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/config-3.11-darwin/libpython3.11.dylib
pythonhome:     /Users/claytonlamb/.virtualenvs/rgee:/Users/claytonlamb/.virtualenvs/rgee
version:        3.11.5 (v3.11.5:cce6ba91b3, Aug 24 2023, 10:50:31) [Clang 13.0.0 (clang-1300.0.29.30)]
numpy:          /Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/numpy
numpy_version:  1.26.0
ee:             /Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee

NOTE: Python version was forced by RETICULATE_PYTHON

Description

Just trying to download a DEM, and can't get it to work.

What I Did

dem <- ee$
  Image("NASA/ORNL/DAYMET_V4")$
  select("elevation")

Map$addLayer(dem,
  list(min=0, max=2000, palette = palette))

Error in py_call_impl(callable, call_args$unnamed, call_args$named) :
ee.ee_exception.EEException: Can't encode object: <function make_python_function.<locals>.python_function at 0x2857c9580>
Run `reticulate::py_last_error()` for details.
11.
stop(<environment>)
10.
_encode_cloud_object at serializer.py#265
9.
encode_cloud_value at computedobject.py#152
8.
_encode_cloud_object at serializer.py#221
7.
_encode_for_cloud_api at serializer.py#98
6.
_encode at serializer.py#80
5.
encode at serializer.py#298
4.
getMapId at data.py#553
3.
ee$data$getMapId(list(image = image))
2.
get_ee_image_url(image)
1.
Map$addLayer(dem, list(min = 0, max = 2000, palette = palette))

── Python Exception Message ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Traceback (most recent call last):
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/data.py", line 553, in getMapId
    serializer.encode(params['image'], for_cloud_api=True),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/serializer.py", line 298, in encode
    return serializer._encode(obj)  # pylint: disable=protected-access
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/serializer.py", line 80, in _encode
    return self._encode_for_cloud_api(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/serializer.py", line 98, in _encode_for_cloud_api
    value = self._encode_cloud_object(obj)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/serializer.py", line 221, in _encode_cloud_object
    result = obj.encode_cloud_value(self._encode_cloud_object)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/computedobject.py", line 152, in encode_cloud_value
    encoded_args[name] = {'valueReference': encoder(value)}
                                            ^^^^^^^^^^^^^^
  File "/Users/claytonlamb/.virtualenvs/rgee/lib/python3.11/site-packages/ee/serializer.py", line 265, in _encode_cloud_object
    raise ee_exception.EEException('Can\'t encode object: %s' % obj)
ee.ee_exception.EEException: Can't encode object: <function make_python_function.<locals>.python_function at 0x2857c9580>

── R Traceback ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    ▆
 1. └─Map$addLayer(dem, list(min = 0, max = 2000, palette = palette))
 2.   └─rgee:::get_ee_image_url(image)
 3.     └─ee$data$getMapId(list(image = image))
 4.       └─reticulate:::py_call_impl(callable, call_args$unnamed, call_args$named)
milesalanmoore commented 1 year ago

@ctlamb The Daymet dataset is not an image, nor does it contain a band "elevation." You can read more about this ImageCollection here: https://developers.google.com/earth-engine/datasets/catalog/NASA_ORNL_DAYMET_V4#bands

library(rgee)
ee_Initialize()

roi <- ee$Geometry$Point(c(-122.2575, 37.8795)) %>%
  ee$Geometry$buffer(10000)

dem <- ee$
  ImageCollection("NASA/ORNL/DAYMET_V4")$
  filterBounds(roi)$first()

print(dem$getInfo())
Map$centerObject(roi, zoom = 2)
Map$addLayer(dem, visParams = list(bands = "swe", min = 0, max = 300,
                                   palette = c("lightblue", 'navy', 'purple')))
Screenshot 2023-09-28 at 4 15 18 PM