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.

  1. 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?
1
  • does the same work for Landsat8 also
    – user136408
    Commented Dec 11, 2018 at 16:46

3 Answers 3

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
});
3
  • 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
    Commented Jun 21, 2018 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
    Commented Jun 21, 2018 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
    Commented Jun 21, 2018 at 8:39
0
var S2 = imageCollection
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than', 100)
.filterDate ('1999-08-2','2000-08-20')
.filterBounds(table).select(['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7'])
.sort('CLOUD_COVER') 
.mosaic()
//.first();
print(S2)
var clipimage = S2.clip(table)
Map.addLayer(clipimage)
Export.image.toDrive({
  image: clipimage,
  scale: 30,
  description: 'Landsat7',
  region: table,
  maxPixels: 1e11
});
1
  • 1
    Welcome to GIS SE. As a new user, please take the Tour. Answers should be more than code. This is especially true when the Question has an Answer that was accepted many years previously. What is it about this Answer that addresses the Question not addressed by the existing Answer?
    – Vince
    Commented Oct 4, 2022 at 11:56
0
//var image = ee.ImageCollection("COPERNICUS/S2_SR")
Map.addLayer(table)
var S2 = imageCollection
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE', 'less_than',10)
.filterDate ('2022-10-1','2022-10-25')
.filterBounds(table).select(['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8'])
.sort('CLOUD_COVER') 
.mosaic()
//.first();
print(S2)
var clipimage = S2.clip(table)
Map.addLayer(clipimage)
Export.image.toDrive({
  image: clipimage,
  scale: 10,
  description: 'TTS_Oct',
  region: table,
  maxPixels: 1E10
});
1
  • 1
    Explanations are welcomed
    – MrXsquared
    Commented Jan 10, 2023 at 16:03

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.