0

I am trying to download NO2 data. I search in the forum and read all the topics non of them was helpful for my situation.
https://stackoverflow.com/questions/43868762/exporting-all-images-in-a-google-earth-engine-image-collection-google-earth-eng this was a bit helpful but I could not find the way to implement this on my code.

I read that an image can be downloaded using Export.image.toDrive. I want to download a collection but I don't find a suitable way.

I am getting errors in what I do. here is my code maybe someone can help me.

var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
  .select('tropospheric_NO2_column_number_density')
  .filterDate('2021-09-24', '2021-09-29')
  .filterBounds(no2)
  .map(function(image){return image.clip(no2)});
  
var band_viz = {
  min: 0,
  max: 0.0002,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

Map.addLayer(collection.mean(), band_viz, 'S5P N02');
Map.setCenter(65.27, 24.11, 4);
Export.image.toDrive({
  image: collection,
  description: 'no2',
  folder: '',
  region: no2,
  crs: 'EPSG:4326',
  crsTransform: null,
  formatOptions: null
});
The coordinates I am trying to export;
0: [25.828885323591855,38.86015686381728]
1: [32.376736886091855,38.86015686381728]
2: [32.376736886091855,42.49146173223847]
3: [25.828885323591855,42.49146173223847]
4: [25.828885323591855,38.86015686381728]

when I run the code, the error I got;

ID: 6NWBQV4BQBLYOLHCABGPCVGH
Phase: Failed
Runtime: 1s (started 2022-02-16 17:05:39 +0300)
Attempted 1 time
Error: Image.setDefaultProjection, argument 'image': Invalid type. Expected type: Image<unknown bands>. Actual type: ImageCollection. (Error code: 3)

2 Answers 2

2

You can only export images, not image collections from GEE. What you need to do is export either the average of the images across your collection or convert the collection to an image with many bands. Try this:

var geometry = 
    ee.Geometry.Polygon(
        [[[25.828885323591855,38.86015686381728],
          [32.376736886091855,38.86015686381728],
          [32.376736886091855,42.49146173223847],
          [25.828885323591855,42.49146173223847],
          [25.828885323591855,38.86015686381728]]], null, false);
          
Map.centerObject(geometry,6)

var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
  .select('tropospheric_NO2_column_number_density')
  .filterDate('2021-09-24', '2021-09-29')
  .map(function(image){return image.clip(geometry)});
  
var band_viz = {
  min: 0,
  max: 0.0002,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

Map.addLayer(collection.mean(), band_viz, 'S5P N02');

//var img = collection.toBands()

//print(img)

Export.image.toDrive({
  image: collection.mean(),
  description: 'no2',
  folder: '',
  region: geometry,
  crs: 'EPSG:4326',
  crsTransform: null,
  formatOptions: null
});

All you needed was to add a .mean() in your export function. If instead you wanted to export all the images as bands of a single image, I made a new variable img = collection.toBands(). However, I don't recommend this because you will export a massive image with more than 70 bands to your google drive. For this reason that part of the code is commented out in my answer. Hope this helps!

3
  • The code works with the implementation you suggest, I appreciated but when I use the new variable img = collection.toBands() I got a no data raster with no data bands.
    – RS_girl
    Feb 17, 2022 at 7:36
  • hmmm, when I run the code I get an image with 71 bands. did you uncomment the two lines by deleting the // in the script? Feb 17, 2022 at 16:48
  • Definitely, I delete. the bands have no data.
    – RS_girl
    Feb 18, 2022 at 6:17
0

Here is the answer of what I exactly wanted to do;

var batch = require('users/fitoprincipe/geetools:batch');
Map.centerObject(no2,6)

var collection = ee.ImageCollection('COPERNICUS/S5P/OFFL/L3_NO2')
  .select('tropospheric_NO2_column_number_density')
  .filterDate('2021-09-24', '2021-09-26')
  .filterBounds(no2);
  
print(collection)  
var band_viz = {
  min: 0,
  max: 0.0002,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};

batch.Download.ImageCollection.toDrive(collection, "test", {region:no2, crs: 'EPSG:4326'});

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.