1

I am trying to export a CSV file from Google Earth Engine (GEE) that reflects the mean EVI value per census tract. I have script that does this exact thing for NDVI from Landsat 8 but cannot seem to get the code to work for EVI. I understand that in my NDVI script I have specific bands but being unfamiliar with Java I cannot seem to figure out how to edit it for EVI.

Script to Export mean NDVI per Census Tract:


var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
    .filterDate('2015-05-01', '2015-09-30')


var count = collection.size();
print('Number of images in collection:', count)

var composite = ee.Algorithms.Landsat.simpleComposite(collection)

var compBands = composite.bandNames()
print('Composite bands:', compBands)

var NDVIcomp = composite.normalizedDifference(['B5', 'B4']).rename('NDVI')

Map.addLayer(NDVIcomp, {min: -1, max: 1, palette: ['blue', 'white', 'green']}, 'NDVI_')
Map.addLayer(UStracts)

var bandNames = NDVIcomp.bandNames()
print('Band names:', bandNames)

//US Census Tracts
var meansCT = NDVIcomp.reduceRegions({
  collection: UStracts,
  reducer: ee.Reducer.mean(),
  scale: 30,
});

Export.table.toDrive({
    collection: meansCT, 
    description: 'US Tracts', 
    folder: 'Aim1', 
    fileNamePrefix: 'UStracts', 
    fileFormat: 'CSV'
})

1 Answer 1

0

You should focus your question as much as possible. I this case, I suppose that you actually want to know how to calculate EVI? Also, make sure you have a fully functional script, ideally with a link to the Earth Engine Code Editor script (use the Get Link button). Here, UStracts is undefined, so I cannot execute your script.

Here's one way to calculate EVI:

var composite = ee.Algorithms.Landsat.simpleComposite(collection)
  .select( // Rename used bands
    ['B2', 'B3', 'B4', 'B5'],
    ['blue', 'green', 'red', 'nir']
  )

var EVIcomp = ee.Image().expression(
  'G * ((i.nir - i.red) / (i.nir + C1 * i.red - C2 * i.blue + L))', 
  {
    i: composite.divide(255), // simpleComposite() multiply by 255
    L: 1,
    C1: 6,
    C2: 7.5,
    G: 2.5
  }
).rename('EVI')

https://code.earthengine.google.com/955834ef6f91ae1a3c7977b187d4f950

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.