1

When I run the below code, I am getting only shapefile boundary in color, and inside the border does not visualize any temperature as per the color bar.

/////////////////////////////////////////////////////

// Create a FeatureCollection from the list and print it.
var table = ee.FeatureCollection('users/nidhivermaiiita/district');
print(table);
Map.centerObject(table);
Map.addLayer(table);
var dataset = ee.ImageCollection('MODIS/006/MOD11A1')
.filterBounds(table)
.filter(ee.Filter.date('2020-03-30', '2020-04-29'));
var landSurfaceTemperature = dataset.select('LST_Day_1km');
var landSurfaceTemperatureVis = {
  min: 13000.0,
  max: 16500.0,
  palette: [
    '040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
    '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
    '3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
    'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
    'ff0000', 'de0101', 'c21301', 'a71001', '911003'
  ],
};
//Map.setCenter(6.746, 46.529, 2);
//Map.addLayer(landSurfaceTemperature, landSurfaceTemperatureVis, 'Land Surface Temperature');

// map over the image collection and use server side functions
var tempToDegrees = landSurfaceTemperature.map(function(image){
  var LST=image.multiply(0.02).subtract(273.15).rename('LST');
  return image.addBands(LST);
});
// Create a chart.
var chart = ui.Chart.image.series({
  imageCollection: tempToDegrees.select('LST'),
  region: table,
  reducer: ee.Reducer.mean(),
  scale: 30
}).setOptions({title: 'Land Surface Temperature'});



// Display the chart in the console.
print(chart);
// print and add to the map
//print('image collection in temp in degrees', tempToDegrees);

// Create and print the chart.
print(ui.Chart.image.series(landSurfaceTemperature,table, ee.Reducer.mean(), 30));
//Map.addLayer(landSurfaceTemperature, landSurfaceTemperatureVis, 'LST');
// print and add to the map
//print('image collection in temp in degrees', tempToDegrees);
//Map.addLayer(tempToDegrees, {min: -20, max: 60, palette: landSurfaceTemperatureVis.palette}, 'temp in degrees');
var landSurfaceTemperature = dataset.select('LST_Day_1km').mean();
var landSurfaceTemperatureVis = {
  min: 13000.0,
  max: 16500.0,
  palette: [
    '040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
    '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
    '3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
    'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
    'ff0000', 'de0101', 'c21301', 'a71001', '911003'
  ],
};
{
var image = landSurfaceTemperature.clip(table);
print(image, 'image');
Map.addLayer(image, landSurfaceTemperatureVis);
}
var mean = image.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: table,
  scale: 30
});

// Print the result (a Dictionary) to the console.
print(mean);
Export.image.toDrive({
  image: landSurfaceTemperature,
  description: 'LST_Haryana',
  scale: 30,
   fileFormat: 'GeoTiFF',
  folder: 'GEE',
  region:table
});
2
  • Your table asset is not imported so we can't test your script. Please include a line of code that imports the table (ensure that the asset is shared). I can get the script to work properly using an arbitrary rectangle (example). Commented Jun 24, 2020 at 12:58
  • Share your Earth Engine asset upload of the table. People are not going to want to deal with uploading it themselves. Please make it as easy as you can for people to understand the problem and answer the question. Commented Jun 24, 2020 at 17:30

1 Answer 1

2

You can visualize the time series per region by mapping a reduceRegion function over all combinations of LST image and region. I've included an example in the script below. Note that you need to export the resulting FeatureCollection as an asset, since the job is too big to run interactively in the browser (it should only take about 5 minutes to complete the export - please read code comments). As for overlaying the region boundary lines on mean LST, use the paint() function to "paint" the boundary lines to a blank raster (see code).

enter image description here

Note that I've used a public FeatureCollection for demonstration.

Code Editor script

// Import counties.
var counties = ee.FeatureCollection("TIGER/2018/Counties")
  .filter(ee.Filter.eq('STATEFP', '41'));
print(counties);

// Import LST.
var lst = ee.ImageCollection('MODIS/006/MOD11A1')
  .filterBounds(counties)
  .filterDate('2020-03-30', '2020-04-29')
  .select('LST_Day_1km');

// Add LST units as degrees c as new band.
var tempToDegrees = lst.map(function(image){
  var degreesC = image.multiply(0.02).subtract(273.15).rename('LST');
  return image.addBands(degreesC);
});

// Make a LST time series per county in FeatureCollection.
var lstTsByCounty = counties.map(function(county) {
  return tempToDegrees.map(function(img) {
    // Reduce precision of county boundaries to match the LST resolution;
    // avoids issues with exceeding memory limit.
    var geom = county.geometry().simplify(1000); 
    var stat = img.select(['LST']).reduceRegion({
      reducer: ee.Reducer.mean(),
      geometry: geom,
      scale: 1000,
      bestEffort: true,
      maxPixels: 1e13,
      tileScale: 4
    });
    return ee.Feature(geom, stat)
      .copyProperties(county, ['NAME'])
      .set('system:time_start', img.get('system:time_start'));
  });
}).flatten();

// Export the LST time series per county FeatureCollection. The job is
// too big to handle interactively.
Export.table.toAsset({
  collection: lstTsByCounty,
  description: 'lstTsByCounty',
  assetId: 'gis_se_q_365561_68792'
});

// After the export finishes- load the FeatureCollection to view the chart.
// You'll need to change the path to your own account.
var lstTs = ee.FeatureCollection("users/braaten/gis_se_q_365561_68792");
print(lstTs.limit(5));

// Chart the LST time series of all the counties.
// If you don't like all of the counties in the same chart,
// filter the lstTs collection by the 'NAME' property. 
var chart = ui.Chart.feature.groups({
  features: lstTs,
  xProperty: 'system:time_start',
  yProperty: 'LST',
  seriesProperty: 'NAME'
});
print(chart);

// Display LST to Map.
var landSurfaceTemperatureVis = {
  bands: ['LST'],
  min: -10,
  max: 35,
  palette: [
    '040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
    '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
    '3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
    'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
    'ff0000', 'de0101', 'c21301', 'a71001', '911003'
  ],
};
Map.centerObject(counties);
Map.addLayer(
  tempToDegrees.mean()
  .clipToCollection(counties), landSurfaceTemperatureVis, 'LST');

// Display the county boundaries.
var countyLines = ee.Image().byte().paint({
  featureCollection: counties,
  color: 1,
  width: 2
});
Map.addLayer(countyLines, {palette: '000000'}, 'countys');
Map.setOptions('SATELLITE');
10
  • Many thanks for the reply. I want to visualize the LST of the subdistric area as well. The subdistric id are mentioned in table asset. Commented Jun 24, 2020 at 19:53
  • 1
    What do you mean by "visualize": 1) Overlay the district outlines on the LST map display or 2) visualize the LST time series chart per district? Commented Jun 24, 2020 at 20:51
  • Thanks. Yes, I want do these two: 1) Overlay the district outlines on the LST map display and 2) visualize the LST time series chart per district? Commented Jun 25, 2020 at 2:32
  • 1
    The MODIS data are 1km (1000m) resolution pixels, setting the scale to 30m gives no extra precision, it will only make the analysis slower. 30m would be appropriate for Landsat data. Commented Jun 26, 2020 at 18:07
  • 1
    Best thing would be to use the scale that is include as metadata from the dataset: img.projection().nominalScale() Commented Jun 26, 2020 at 20:11

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.