TransWikia.com

Creating NDVI time series graphs from buffered point (vegetation plot) locations in Google Earth Engine

Geographic Information Systems Asked by Rachel Gray on May 6, 2021

I am aware there are a lot of similar questions to this on here like

but I couldn’t quite find one that helped me.

I am looking at tree death from drought and I have on ground survey data as polygons(plots) and points.

I am trying to get an NDVI time series graph for each buffered point (user defined in map window as geometry2) using Landsat 8 32 day composites. Id like to see if NDVI can show the decline in tree health (and death) over time at these point locations (with 100m buffer).

Ideally I would like a mean value for each poly or point(buffered 100m) for every L8 32day NDVI composite from Dec2017-Dec2020(present).

I keep getting the error:
"image" is not defined in this scope.
in , line 122
But the code doesn’t have a line 122.

// Load Landsat 8 Collection 1 Tier 1 32-Day NDVI Composite input imagery.
var landsat8NDVI32d = ee.ImageCollection('LANDSAT/LC08/C01/T1_32DAY_NDVI')
    .filterDate('2017-12-01', '2020-12-01')
    .select('B[1]');

// Define regions of interest as 100M buffers around points.
var geometry = ee.Geometry.Point(geometry2).buffer(100);

// Reduce the region. 
var meanDictionary = image.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: region.geometry(),
  scale: 30,
  maxPixels: 1e9
});

// Create a graph of the time-series.
var graph = ui.Chart.image.seriesByRegion({
  imageCollection: landsat8NDVI32d, 
  regions: geometry, 
  reducer: ee.Reducer.mean()
})
print(graph)

One Answer

Sometimes line numbers are a little (or a lot) off. The Earth Engine team is aware that getting this better will greatly help debugging, and we're working on it.

You have the variable image used on line 10:

var meanDictionary = image.reduceRegion({

You also have the undefined variable region on line 12:

  geometry: region.geometry(),

However, both of these, once removed, don't actually affect the results because meanDictionary is never used, so you could delete that entire block of code and get the same answer.

Deleting that shows an unfortunate error message "Unknown variable references" which appears to be due to ee.Geometry.Point(geometry2), which is not valid: ee.Geometry.Point is only for constructing geometry from coordinates. You'll want to instead just call .buffer(100), inside a map if geometry2 is a feature collection.

Next up:

Image.select: Pattern 'B[1]' did not match any bands.

which is true, because the only band of LANDSAT/LC08/C01/T1_32DAY_NDVI is named NDVI. So you don't actually need the .select('B[1]') call at all.

Removing that, our next problem is

The default WGS84 projection is invalid for aggregations. Specify a scale or crs & crs_transform.

You'll want to specify a scale corresponding to the number of points sampled you want within your buffered circles.

Answered by Kevin Reid on May 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP