I am trying to convert my google earth engine image to a numpy array. I have used sampleRectangle but the scale seems to be set to 1 degree, way too large, even though the native resolution of the dataset is much smaller.
import numpy as np
import ee
ee.Authenticate()
ee.Initialize()
def get_mod16(date1,date2,geometry):
mod16 = ee.ImageCollection('MODIS/006/MOD16A2')
mod16_img = mod16.filterDate(date1,date2).select('ET').sum().multiply(10)
return(mod16_img)
def addGeometry(min_lon,max_lon,min_lat,max_lat):
geom = ee.Geometry.Polygon(
[[[min_lon, max_lat],
[min_lon, min_lat],
[max_lon, min_lat],
[max_lon, max_lat]]])
return(geom)
geom = addGeometry(-102, -97.76,37.0727,38.5997)
mod16 = get_mod16('2014-04-01','2014-10-01',geom)
array = mod16.sampleRectangle(region=geom)
nparray = np.array(array.get('ET').getInfo())
print(nparray.shape)
This returns an np array of size (2,5). I thought maybe it's because my region is too large. I modified the code so the region is quite small (0.01 degrees by 0.01 degrees). It then returns an array of size (1,1).