0

I want to download the daily tmax from the NASA for a given lat lon (https://developers.google.com/earth-engine/datasets/catalog/NASA_NEX-DCP30_ENSEMBLE_STATS) using the following tutorial https://jesjehle.github.io/earthEngineGrabR/index.html

library(devtools)
install_github('JesJehle/earthEngineGrabR')
library(earthEngineGrabR)
ee_grab_install() # had to install Anaconda before doing this step.

test_data <- ee_grab(data = ee_data_collection(datasetID = "NASA/NEX-DCP30_ENSEMBLE_STATS",
                                               timeStart = "1980-01-01",
                                               timeEnd = '1980-01-02',
                                               bandSelection = 'tasmax'), 
    targetArea = system.file("data/territories.shp", package = "earthEngineGrabR")
    )

Error: With the given product argument no valid data could be requested.
In addition: Warning message:
Error on Earth Engine servers for data product: NASA-NEX-DCP30_ENSEMBLE_STATS_s-mean_t-mean_1980-01-01to2005-12-31
Error in py_call_impl(callable, dots$args, dots$keywords): EEException: Collection.first: Error in map(ID=historical_195001):
Image.select: Pattern 'tasmax' did not match any bands.

I would like to know how to specify the bandwidth so that I do get this error and instead of using a shapefile as target area, I do I download tmax data for a single lat lon 9.55, 78.59?

89_Simple
  • 3,393
  • 3
  • 39
  • 94

1 Answers1

1

You might use rgee to accomplish this. Currently, rgee has a function called rgee::ee_extract that works similar to raster::extract().

library(rgee)
library(sf)

# 1. Load a geometry
y <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) %>%
  st_transform(4326)
## Move that geometry from local to earth engine
ee_y <- sf_as_ee(y)

# 2. Load your ImageCollection
x <- ee$ImageCollection("NASA/NEX-DCP30_ENSEMBLE_STATS")$
  filterDate("1980-01-01","1980-01-02")$
  map(function(img) img$select("tasmax_mean"))
## calculate the nominal scale
scale <- x$first()$projection()$nominalScale()$getInfo() 

# 3. Extract values
tasmax_mean_data <- ee_extract(x = x,
                               y =  y, 
                               fun = ee$Reducer$mean(),
                               scale = scale, 
                               id = "FIPS")

# 4. Merge results with the sf object
ee_nc_tasmax <- merge(y, tasmax_mean_data, by = "FIPS")
plot(ee_nc_rain['historical_198001'])
csaybar
  • 179
  • 1
  • 5