Google Earth Engine – How to Retrieve Land Surface Temperature (LST) for Multiple Areas Simultaneously

google-earth-enginegoogle-earth-engine-javascript-api

I'm fairly new to GEE/Javascript so my terminology may be wrong and confusing.

I have a Shapefile with polygons for 1000ish cities of interest. I'm trying to retrieve the LST for those cities; the ultimate goal is to export a .csv file that'll show the LST for each of those cities for my selected time frame.

I'm struggling with using reduceRegions to aggregate/dissolve my pixels based on each city's boundaries. GEE just highlights my code in red (marked in my code below), with no hint of what the error may be. I'm also unsure about how to export to a .csv file, but attempted to write some code.

//I uploaded a Shapefile of my cities into my assets.
var cities = ee.FeatureCollection('file path'); 

// Import LST from MODIS and filter dates
var modis = ee.ImageCollection("MODIS/006/MOD11A1");
var winter_day = modis.filter(ee.Filter.date('2009-12-01', '2010-03-01')).select('LST_Day_1km');

// set boundary value to zero
var value = 0;

// Convert to Celsius. 
var winter_day_C = winter_day.map(function(image) {
  return image
    .multiply(0.02)
    .subtract(273.15)
    .copyProperties(image, ['system:time_start']);
});

// Reduce LST data to Shapefile with cities. **This is the section that GEE highlights in red.**
var Winter_Day_LST = Winter_Day_LST.reduceRegions({
  collection: cities,
  reducer: ee.Reducer.mean(),
  scale: 100,
});

// NOTE - I do not know if the following code will work, but GEE will not run this because of the above error.

// Remove geometry on each feature before printing or exporting (set geom to null)
var WinterDayLST_export = Winter_Day_LST.select(['.*'],null,false);

// Export 
Export.table.toDrive({
  collection: WinterDayLST_export,
  description: '2010_WinterDayLST_export',
  fileFormat: 'CSV'
});

Best Answer

You define your variable as winter_day_C but later call it as Winter_Day_LST. That's why Earth Engine highlights that part, Winter_Day_LST isn't defined yet at that point.