Export sentinel-5P image collection using GEE

google-earth-enginesentinel 5p

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)

Best Answer

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!

Related Question