1

So I have a date range of MODIS temperature images that I am attempting to export from GEE for use in Google Earth. This is what the code looks like thus far:

var dataset = ee.ImageCollection('MODIS/006/MYD11A2')
                  .filter(ee.Filter.date('2018-05-01', '2018-06-01'));
var landSurfaceTemperature = dataset.select('LST_Day_1km');
var landSurfaceTemperatureVis = {
  min: 14000.0,
  max: 16000.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(-85.60371794450282,44.73590436363271, 8);
Map.addLayer(
    landSurfaceTemperature, landSurfaceTemperatureVis,
    'Land Surface Temperature');

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

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:

// Export the image, specifying scale and region.
Export.image.toDrive({
  image: dataset.filter('LST_Day_1km'),
  description: 'Overlay',
  scale: 30,
  region: features
});

So what do I need to add to that code to facilitate the export of the color-coded data set into a .kmz, GeoTIFF or some sort of file that could be overlayed in Google Earth? Do I need to .sum() the image set prior to export?

This is for personal use, so I do not need to embed it into a website, so I don't think I will need to use the API provided by Earth Engine....or do it?

EDIT:

After trying the below suggestion, this is what happened.

After I added the .mean() function, I could then export an image. Without that, I couldn't as I would get the error " Error: Invalid argument: 'image' must be of type Image."

I was able to successfully export a .tif that could be read in google earth when I added .mean()

Export.image.toDrive({ 
image: landSurfaceTemperature.mean(), 
description: 'Overlay', 
scale: 30, 
region: features });

However, the imported image was entirely white (no data or visualization.) I'm wondering if it has to do with exporting the landSurfaceTemperatureVis variable, however when attempting to export that variable I get an error saying that it's not a valid variable to export.

Any suggestions?

EDIT 2:

Still getting a white image upon importation to Google Earth.

1

You just need to change the input dataset and scale in your export:

// 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: 14000.0,
  max: 16000.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(-85.60371794450282,44.73590436363271, 8);
Map.addLayer(
    landSurfaceTemperature.filterDate("2018-05-01"), landSurfaceTemperatureVis,
    'Land Surface Temperature May 1');
Map.addLayer(
    landSurfaceTemperature.filterDate("2018-05-09"), landSurfaceTemperatureVis,
    'Land Surface Temperature May 9');
Map.addLayer(
    landSurfaceTemperature.filterDate("2018-05-17"), landSurfaceTemperatureVis,
    'Land Surface Temperature May 17');
Map.addLayer(
    landSurfaceTemperature.filterDate("2018-05-25"), landSurfaceTemperatureVis,
    'Land Surface Temperature May 25');
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)
// Export the image, specifying scale and region.

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

In R, you can then run

image(raster("OUTPUTIMAGE.tif"))

to verify that it worked.

Edit: To follow up, EarthEngine only exports images in TIFF and TFRecord formats, so you won't be able to export a kmz or something like that. But, you can open TIF's in Google Earth Pro anyway.

  • I was able to successfully export a .tif that could be read in google earth when I added this: Export.image.toDrive({ image: landSurfaceTemperature.mean(), description: 'Overlay', scale: 30, region: features }); the imported image was entirely white (no data or visualization.) I'm wondering if it has to do with exporting the landSurfaceTemperatureVis variable, however when attempting to export that variable I get an error saying that it's not a variable. Additionally, when I ran your code as is, i got " Error: Invalid argument: 'image' must be of type Image." – Joey Roses Dec 20 '18 at 20:49
  • Your scale is set to 30 but MYD11A2 imagery is at 1000m resolution. That may be the problem. See updated answer. – JepsonNomad Dec 20 '18 at 21:05
  • Still getting a white overlay in GE. Also...pardon my ignorance, but when you say "In R, you can then run "image(raster("OUTPUTIMAGE.tif"))", what does that mean? Where should I input that string? – Joey Roses Dec 20 '18 at 21:17
  • Once you export image to drive in GEE (using "OUTPUTIMAGE.tif" or whatever it ends up being called), you can download it onto your computer. In R if you just navigate to your downloads folder using setwd("path/to/directory") you can load the image and display is using the raster package (library(raster)) with image(raster("OUTPUTIMAGE.tif")). The Google Earth visualization is a separate issue from the GEE export. – JepsonNomad Dec 20 '18 at 21:20
  • Ok, updated code includes vizualization parameters so it works in Google Earth Pro. Checked on Macbook Pro. – JepsonNomad Dec 20 '18 at 21:36
0

This was the final script:

// 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)
// Export the image, specifying scale and region.

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

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.