1

As you can see using the code below in Earth Engine, the resolution of the MODIS images are 1km squares that look quite obtuse.

// Create a geometry representing an export region.
var features = ee.Geometry.Rectangle([-85.1417893413635, 45.31413490213395, -86.125065708551, 44.65070625463291]);
Map.addLayer(features);
print("features",features);

// This function clips images to the ROI feature collection
var clipToCol = function(image){
  return image.clip(features);
};

var dataset = ee.ImageCollection('MODIS/006/MYD11A2')
                  .filter(ee.Filter.date('2018-05-01', '2018-06-01'))
                  .map(clipToCol);
print("dataset",dataset);
var landSurfaceTemperature = dataset.select('LST_Day_1km');
print("lST",landSurfaceTemperature);
var landSurfaceTemperatureVis = {
  min: 14375.62,
  max: 15300.38,
  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(-85.60371794450282,44.93590436363271, 10);
Map.addLayer(
    landSurfaceTemperature.filterDate('2013-04-10', '2013-05-10'), landSurfaceTemperatureVis,
    'Land Surface Temperature 13');
Map.addLayer(
    landSurfaceTemperature.filterDate('2014-04-10', '2014-05-10'), landSurfaceTemperatureVis,
    'Land Surface Temperature 14');
Map.addLayer(
    landSurfaceTemperature.filterDate('2015-04-10', '2015-05-10'), landSurfaceTemperatureVis,
    'Land Surface Temperature 15');
Map.addLayer(
    landSurfaceTemperature.filterDate('2016-04-10', '2016-05-10'), landSurfaceTemperatureVis,
    'Land Surface Temperature 16');
Map.addLayer(
    landSurfaceTemperature.filterDate('2017-04-10', '2017-05-10'), landSurfaceTemperatureVis,
    'Land Surface Temperature 17');
Map.addLayer(
    landSurfaceTemperature.filterDate('2018-04-10', '2018-05-10'), landSurfaceTemperatureVis,
    'Land Surface Temperature 18');
Map.addLayer(
    landSurfaceTemperature.mean(), landSurfaceTemperatureVis,
    'Land Surface Temperature Mean May');

// Where I am having trouble is coding the export feature that would allow for an overlay to be placed into Google Earth. This is what I have now:
print(landSurfaceTemperature.mean());
// Visualize image
var imageRGB = landSurfaceTemperature.mean().visualize(landSurfaceTemperatureVis);

print(imageRGB);
Map.addLayer(
  imageRGB)

// Define a boxcar or low-pass kernel.
var boxcar = ee.Kernel.square({
  radius: 200, units: 'pixels', magnitude: true
});

// Smooth the image by convolving with the boxcar kernel.
var smooth = imageRGB.convolve(boxcar);
Map.addLayer(smooth, imageRGB, 'smoothed');


// Export the image, specifying scale and region.

Export.image.toDrive({
  image: imageRGB,
  description: 'Overlay',
  scale: 5,
  region: features,
  maxPixels: 400000000,
});

I've been exploring convolution formulas for linear smoothing based on a per-pixel basis given a radius, however all of the examples use landsat images that have multiple bands. In the case of this code, how exactly would you structure it in a way that would achieve a moderate level of smoothing?

This is what I have worked with:

// Define a boxcar or low-pass kernel.
var boxcar = ee.Kernel.square({
  radius: 200, units: 'pixels', magnitude: true
});

// Smooth the image by convolving with the boxcar kernel.
var smooth = imageRGB.convolve(boxcar);
Map.addLayer(smooth, imageRGB, 'smoothed');

That returns the following error:

Invalid argument specified for ee.Number(): true

What am I doing wrong? Is convolutions the correct method to use to smooth this data set?

1

The code you wrote almost worked. There were three things missing:

  1. the argument 'magnitude' should be a floating value instead of a Boolean (true/false)

  2. a kernel with a radius of 200 is way to large. Set it to 2-10 to make it useful and working. A pixel 200 pixels away from each other are definitely not related to each other.

  3. in Map.addLayer where you add the smoothed image to the map, you set an image as visible parameters.

Below I added the piece of code you should replace:

// Define a boxcar or low-pass kernel.
var boxcar = ee.Kernel.square({
  radius: 5, units: 'pixels', magnitude: 1
});

// Smooth the image by convolving with the boxcar kernel.
var smooth = imageRGB.convolve(boxcar);
Map.addLayer(smooth, {min: 0, max: 256}, 'smoothed');

Here you will find a link to the code. I added also some explanatory texts when you print things to the console and turned of the non-relevant images for this question. Link to full script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.