Extracting pixel time series from Google Earth Engine

Hope you find useful this tutorial:

http://www.loicdutrieux.net/landsat-extract-gee/examples.html

from geextract import ts_extract, get_date
from datetime import datetime
import numpy as np
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))

# Extract a Landsat 7 time-series for a 500m radius circular buffer around
# a location in Yucatan
lon = -89.8107197
lat = 20.4159611
raw_dict = ts_extract(lon=lon, lat=lat, sensor='LE7',
                      start=datetime(1999, 1, 1), radius=500)

# Function to compute ndvi from a dictionary of the list of dictionaries returned
# by ts_extract
def ndvi(x):
    try:
        return (x['B4'] - x['B3']) / (x['B4'] + x['B3'])
    except:
        pass

# Build x and y arrays and remove missing values
x = np.array([get_date(d['id']) for d in raw_dict])
y = np.array([ndvi(d) for d in raw_dict], dtype=np.float)
x = x[~np.isnan(y)]
y = y[~np.isnan(y)]

# Make plot
plt.plot_date(x, y, "--")
plt.plot_date(x, y)
plt.title("Landsat 7 NDVI time-series Uxmal")
plt.ylabel("NDVI (-)")
plt.grid(True)
plt.show()

I think your problem problem lies in your scale, as you specifically say it should be 1M in your reduceRegion(). The nominal Scale for the MODIS/006/MOD11A1 is 1000M. Set scale to 1000 to see if it works. I can't test it out for you because I don't have the Python module for ee installed properly.


I found the issue. It wasn't the scale, since anything below the native resolution of the product returns the value at the native resolution.

The problem was actually a missing parameter in the following line:

data = im.select(band_name)\
        .reduceRegion(ee.Reducer.first(), point, 1)\
        .get(band_name)

I changed this to:

        data = im.select(band_name)\
        .reduceRegion(ee.Reducer.first(),
                      point,
                      1,
                      crs=projection)\
        .get(band_name)

where projection is equal to the image projection (projection = im.projection().getInfo()['crs']**im.projection().getInfo()['crs']). By specifying the native resolution of the data product, the reduceRegion() method then returns the native value for my pixel location.