0

I need to download one image of the Landsat 7 NDVI 32 day from Google earth engine for the continental United States. Just this specific one image from 2005-08-13 to 2005-09-14. Please see my code below:

//Import Landsat Image
var L7200508NDVI = ee.ImageCollection('LANDSAT/LE7_L1T_32DAY_NDVI')
.filterDate('2005-08-13', '2005-09-14')
.filterBounds(region);

print('L7200508NDVI', L7200508NDVI);
Map.addLayer(L7200508NDVI);

// Load a region representing the United States //this doesn't work as my boundary
var region = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw')
.filter(ee.Filter.eq('Country', 'United States'));
Map.addLayer(region);

// Create a small area to test: geometry representing an export region.
var geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);

// Export the image, specifying scale and region.
Export.image.toDrive({
  image: L7200508NDVI,
  description: 'imageToDriveExample',
  scale: 30,
  region: geometry,
  maxPixels:1e11
});
  1. if I use the test geometry I got the error: Error: Invalid argument: 'image' must be of type Image.

  2. i am not sure how to create a polygon just right for the Continental United States. or do I need import a polygon from my ArcGIS layer?

  • does the same work for Landsat8 also – user136408 Dec 11 '18 at 16:46
2

You are working with an ImageCollection, which contains overlapping images. For export you need a single image. One way to go from an ImageCollection to an image is use a simple reducer such as taking the mean of the overlapping parts.

To mask everything outside the continental clip the image to the region.

Export does not support MultiPolygons. But you can use the bounding box of your region and skip the empty tiles (i.e. the parts you have masked with clip).

// Load a region representing the United States //this doesn't work as my boundary
var region = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw')
.filter(ee.Filter.eq('Country', 'United States'));

//Import Landsat Image
var L7200508NDVI = ee.ImageCollection('LANDSAT/LE7_L1T_32DAY_NDVI')
  // .filterDate('2005-08-13', '2005-09-14')
  .filterBounds(region);

print('L7200508NDVI', L7200508NDVI);

Map.addLayer(L7200508NDVI.mean().clip(region));

// Export the image, specifying scale and region.
Export.image.toDrive({
  image: L7200508NDVI.mean().clip(region),
  description: 'imageToDriveExample',
  scale: 30,
  region: region.geometry().bounds(),
  maxPixels:1e11,
  skipEmptyTiles: true
});
  • Hi, Kersten. Thank you so much for answering. I think I got it for my question 1 about the difference between image and image collection. But for the boundary issue, with your revised code, I think it still clipped the image to the whole U.S. (including Alaska). I saw this from the display by this code line: Map.addLayer(L7200508NDVI.mean().clip(region)); So the bounding box still included Alaska when Export.image.to Drive. I was wondering, is there a way to get rid of Alaska? – titi Jun 21 '18 at 6:17
  • You need to edit the geometry of the Feature you imported to remove alaska or possibly use a different feature collection that allows the selection by state. – Kersten Jun 21 '18 at 7:05
  • Oh, right. Thanks. I draw a polygon around the continental US and imported it as the "region" in the Export.image.toDrive. Everything else is the same. And I got the exact images with continental US that I want. Thanks again, Kersten. – titi Jun 21 '18 at 8:39

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.