I'm trying to extract band values from a Daymet image collection (V4) at specific sampling locations, averaged over the course of year (daily average). I'm using the Google Earth Engine Python API (geemap) to do so. The bands are raster datasets (1 km resolution) of variables such as maximum temperature, shortwave radiation, and other environmental variables.
Currently, I'm able to extract all of the daily values for each band over the time period using the following code:
ee.Initialize()
daymet = ee.ImageCollection('NASA/ORNL/DAYMET_V4') \
.filter(ee.Filter.date('2000-01-01', '2000-12-31'))
DaymetImage = daymet.toBands() ##convert to ee.Image in order to extract_values_to_points
##export data
out_dir = os.path.expanduser('~/Downloads')
out_csv = os.path.join(out_dir, 'daymet2000.csv')
geemap.extract_values_to_points(fc_coords, DaymetImage, out_csv)
##Note: fc_coords contains sampling points (lat/long) and other variables of interest
While this has all of the information I need, the resulting .csv file is bulky and would require a lot of work to clean up. I would like to be able to directly extract the daily average value for each band in the ImageCollection. The code I have so far is:
ee.Initialize()
daymet = ee.ImageCollection('NASA/ORNL/DAYMET_V4') \
.filter(ee.Filter.date('2000-01-01', '2000-12-31')) \
.mean()
And this is where I get stuck. The .mean
function appears to turn it from an ee.ImageCollection to an ee.Image; however, when I try to extract_values_to_points
from this Image, I get the following error message: EEException: Image.reduceRegions: The default WGS84 projection is invalid for aggregations. Specify a scale or crs & crs_transform.
As it is an ee.Image, the toBands()
function (which I used earlier on an ImageCollection) does not work. Is there any way I can extract the average band values from this ImageCollection easily?