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


def get_mod16(date1,date2,geometry):
  mod16 = ee.ImageCollection('MODIS/006/MOD16A2')
  mod16_img = mod16.filterDate(date1,date2).select('ET').sum().multiply(10)

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]]])

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())


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).

1 Answer 1


Carrying out reducers (like your sum()) on an Image Collection gets rid of the original projection and replaces it with the default projection, which has a scale of 1 degree.

So after doing that reduction you would have to reproject your image back to the original projection.

proj = ee.ImageCollection('MODIS/006/MOD16A2').first().projection()
origProj = mod16.reproject(proj)

Also see the documentation for more info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.