0

ui.Chart.image seems to get tripped up by Landsat data. I've encountered the same error using Landsat 5, 7, and 8 and with several shapefiles so I'm confident it isn't a problem with the regions I'm providing. The scale I use (anywhere between 30m and 6km) doesn't make a difference either. The weird thing is this doesn't happen with MODIS data. See here and here for more on reducing MODIS data.

Both series1 and series2 plots fail with the following error:

Error generating chart: Collection.first: Error in map(ID=1): Collection.geometry: Unable to perform this geometry operation. Please specify a non-zero error margin.

Series1 and 2 should show (for series1) individual band values over the course of the year, and (for series2) Band 1 (blue) values for individual counties over the course of the year.

Anyone have ideas on how to get past the error? Reproducible code below.

var cali = ee.FeatureCollection('ft:1S4EB6319wWW2sWQDPhDvmSBIVrD3iEmCLYB7nMM')
  .filter(ee.Filter.eq('StateName', 'California'));
print("cali shape",cali);

// This function clips images to the ROI feature collection
var clipToCol = function(image){
  return image.clipToCollection(cali);
};
print("clipToCol function",clipToCol);

// Load a Landsat collection, map the NDVI function over it.
var collection = ee.ImageCollection('LANDSAT/LT05/C01/T1_TOA')
  .filterDate('2001-01-01', '2001-12-31')
  .filterBounds(cali)
  .map(clipToCol);
print("TOA Col Preview, No Clouds",collection.first());

// Define a chart with one series in the region, averaged by DOY.
// Guide here: https://developers.google.com/earth-engine/charts_image_doy_series
var series1 = ui.Chart.image.doySeries(
    collection);
print("DOY series",series1);

var series2 = ui.Chart.image.doySeriesByRegion(
    collection, "B1", cali, ee.Reducer.mean(), 6000, 
    ee.Reducer.mean(), 
    'label');
print("County series", series2);

1 Answer 1

1

For series 1, the function is missing multiple arguments. You need to provide region and regionReducer. You can supply a single region or it will compute the reducer for the union of regions, in your case is entire California.

In series 2, your feature collection doesn't contain any property with name 'label'. Be careful when creating chart with Landsat for large areas or longer time periods to avoid the memory area. For such cases, it is helpful to export the values.

Please see the following code and some specific comments:

var cali = ee.FeatureCollection('ft:1S4EB6319wWW2sWQDPhDvmSBIVrD3iEmCLYB7nMM')
  .filter(ee.Filter.eq('StateName', 'California'));
print("cali shape",cali);

// This function clips images to the ROI feature collection --- this is unnecessary
var clipToCol = function(image){
  return image.clipToCollection(cali);
};
//print("clipToCol function",clipToCol);

// Load a Landsat collection
var collection = ee.ImageCollection('LANDSAT/LT05/C01/T1_TOA')
  .filterDate('2001-01-01', '2001-12-31')
  .filterBounds(cali);
  //.map(clipToCol); unnecessary
//print("TOA Col Preview, No Clouds",collection.first());

// Define a chart with one series in the region, averaged by DOY.
// Guide here: https://developers.google.com/earth-engine/charts_image_doy_series

var series1 = ui.Chart.image.doySeries(
    collection, ee.Feature(cali.first()), ee.Reducer.mean(), 6000);
print("DOY series",series1);

// you have no property with name 'label' in cali, let's use any other property
// This is expensive and most likely give memory error for 12 months, try 2 months
collection = collection.filterDate('2001-01-01', '2001-02-28');
var series2 = ui.Chart.image.doySeriesByRegion(
    collection, "B1", cali, ee.Reducer.mean(), 6000, 
    ee.Reducer.mean(), 'CntyFips');

print("County series", series2);

Without the MODIS example (script), it is difficult to figure out how that worked.

1
  • Thanks, Ani. Looking back through my scripts it turns out the MODIS code is actually structured a bit differently. Nov 21, 2018 at 1:04

Your Answer

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

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