如何在Google Earth Engine中编写循环批量导出时序影像?
Batch Export GOES-16 FRP Images in Earth Engine
Got it, let's get you set up to batch export all those 287 FRP images instead of doing it one by one! The key here is to leverage client-side JavaScript looping (since Earth Engine's server-side functions can't directly trigger export tasks) to create export jobs for every image in your date range.
Modified Script for Batch Export
Here's the updated code that will generate export tasks for all images in your 2021-08-05 to 2021-08-06 window, with filenames formatted as FRP0, FRP1, ..., FRP286:
var USgeometry = ee.Geometry.Rectangle({coords: [-122.15, 41.25, -121.25, 42], geodesic: false}); Map.centerObject(USgeometry, 10); // Clip images to your ROI var clipToCol = function(image){ return image.clip(USgeometry); }; // Load and filter the image collection var collection = ee.ImageCollection('NOAA/GOES/16/FDCC') .filterDate('2021-08-05', '2021-08-06') .map(clipToCol); var listOfImages = collection.toList(collection.size()); // Get total image count (convert server-side value to client-side) collection.size().evaluate(function(totalImages) { // Loop through each image index for (var i = 0; i < totalImages; i++) { var image = ee.Image(listOfImages.get(i)); var powerBand = image.select('Power'); // Create export task for each image Export.image.toDrive({ image: powerBand, description: 'FRP' + i, crs: 'EPSG:3031', scale: 100, region: USgeometry, folder: 'GOES_FRP_Batch' // Optional: Organize exports in a Drive folder }); } });
Key Changes & Notes
- Client-Side Looping: We use
.evaluate()to pull the total number of images from Earth Engine's server to your browser (client-side), so we can use a standard JavaScriptforloop to iterate over each image. - Auto-Naming: The
descriptionfield uses'FRP' + ito automatically generate sequential filenames matching your request. - Optional Folder: Adding the
folderparameter will save all exports to a dedicated Google Drive folder (it will create the folder if it doesn't exist), which keeps your Drive organized.
How to Run the Batch Exports
- Paste this script into the Earth Engine Code Editor and run it.
- Click the Tasks tab in the top-right corner of the editor—you'll see all 287 export tasks listed there.
- Select all tasks (hold Ctrl/Cmd to multi-select), then click the Run button for any selected task to start them all at once.
Important Tips
- Storage Check: Make sure your Google Drive has enough space for all exports. Each 100m-resolution image will be a few MB, so total usage should be manageable, but double-check to avoid failures.
- Rate Limits: Earth Engine has limits on concurrent export tasks. If you run into errors, try splitting the batch into smaller groups (e.g., 50 tasks at a time) instead of running all 287 at once.
内容的提问来源于stack exchange,提问作者Sean f
相关产品推荐
相关产品推荐

