1

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'
});

1 Answer 1

2

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.

2
  • Ah thanks for catching that silly mistake. So I corrected the code to winter_day_C, but now GEE tells me that "winter_day_C.reduceRegions is not a function." Any ideas what's wrong?
    – Cat C
    Aug 14, 2021 at 1:08
  • 1
    .reduceRegions() can only be applied to an image, winter_day_C is an image collection. put it in a function that will .map() to the collection an you will have the result you need. Aug 14, 2021 at 9:53

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.