1

I want to graph the NDVI series by another classified image, but when I graph it there is a wrong No features contain non-null values of "system:index". Howvever I already set the system:index.

var dem=ee.Image("USGS/SRTMGL1_003"); 
var roidem=dem.clip(roi); 
var product=ee.Terrain.products(roidem);
var aspect=product.select('aspect'); 
var asp=aspect.expression("(b('aspect')>90) ? 2"+                        ":(b('aspect')>270)?1"+ 
":1")
.rename("aspect")

var roi =   
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-123.764453125, 41.955158501392994],
          [-123.764453125, 39.151105474903886],
          [-119.98515625, 39.151105474903886],
          [-119.98515625, 41.955158501392994]]], null, false);
var aspect=product.select('aspect');

var years2 = ee.List.sequence(2013, 2021);

var  landsat_NDVI_Y2 = ee.ImageCollection(years2.map(function(y){//if without imagecollection this will return list
  var start = ee.Date.fromYMD(y,1,1)
  var end = start.advance(12,'month')
  var ndvi = ee.ImageCollection('LANDSAT/LC08/C01/T1_32DAY_NDVI')
              .filterDate(start,end)
              .select('NDVI')
              .max()
              .set('time',y)
  return ndvi.clip(roi)             
}))

print(landsat_NDVI_Y2,'landsat_NDVI_Y2')

var asp_class = asp.eq([1,2])

print(asp_class,'asp_class')

var ndvi_aspct = landsat_NDVI_Y2.map(function(image){
  return image.multiply(asp_class).set(image.toDictionary(image.propertyNames()));
})

var aspct1 = ndvi_aspct.select(0)
var aspct2 = ndvi_aspct.select(1)
print(aspct1,'aspect1')
print(aspct2,'aspect2')

var chart = ui.Chart.image.series({imageCollection:aspct1,
                       region:roi, 
                       reducer:ee.Reducer.mean(), 
                       scale:30, 
                       xProperty:'system:index'})
print(chart)  
3
  • Add asp to make this example reproducible
    – aldo_tapia
    May 2, 2022 at 13:05
  • I couldn't reproduce the error, my only issue was maxPixels error. You can increase the scale or reduce the data in a previous step, then plot. Check this answer: gis.stackexchange.com/questions/329315/…
    – aldo_tapia
    May 2, 2022 at 13:49
  • I could reproduce the error by also using @aldo_tapia sugestion related to scale. Please, see my answer.
    – xunilk
    May 2, 2022 at 15:17

1 Answer 1

0

You are pointing out that already set the system:index but is not true. It can be easily corroborated by using your original Image Collection where is not included that property. As it was well pointed out by aldo_tapia, there is also exists a scale issue. Following code includes a 'system:time_start' property for generating the chart by using a scale of 300.

var roi =   
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-123.764453125, 41.955158501392994],
          [-123.764453125, 39.151105474903886],
          [-119.98515625, 39.151105474903886],
          [-119.98515625, 41.955158501392994]]], null, false);

var years2 = ee.List.sequence(2013, 2021);

var  landsat_NDVI_Y2 = ee.ImageCollection(years2.map(function(y){//if without imagecollection this will return list
  var start = ee.Date.fromYMD(y,1,1)
  var end = start.advance(12,'month')
  var ndvi = ee.ImageCollection('LANDSAT/LC08/C01/T1_32DAY_NDVI')
              .filterDate(start,end)
              .select('NDVI')
              .max()
              .set('time',y)
              .set('system:time_start', start);
  return ndvi.clip(roi)             
}))

print(landsat_NDVI_Y2,'landsat_NDVI_Y2')

var chart = ui.Chart.image.series({imageCollection:landsat_NDVI_Y2,
                       region:roi, 
                       reducer:ee.Reducer.mean(), 
                       scale:300, 
                       xProperty:'system:time_start'})
print(chart) 

Result of running it in GEE code editor is as follows; where it can be observed a 'system:time_start'. With your original code was not generated error because you used xProperty:'system:index'; not 'system:time_start'. However, error is immediately produced by using 'system:time_start' property.

enter image description here

Now, you only have to adapt above code to use aspct1 variable.

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.