Skip to main content
edited title
Link
Jackk
  • 533
  • 4
  • 20

Loop clipping Imagecollection by features of a vector in Earth Engine and exporting all tifs

added 745 characters in body
Source Link
Jackk
  • 533
  • 4
  • 20

I am looking for a method to clip all the images in an ImageCollection through all the features of a vector (world borders), and then save the resulting tifs in my Google Drive.

So far I wrote this script, which does not work but it gives an idea of what I would like to do. A part for looping over the save with the corresponding filename is missing, as I am not sure how to write it.

var coll = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG').select('avg_rad');
var geometry = ee.FeatureCollection("users/gg/gadm");

var loop = function(image, feature){
    var collection_roi = image.clip(feature);

  // missing part to save each output to drive

    }

var stacked = loop(coll, geometry);

Edit:

Using the following code I did manage to create two-argument loop. However, I end up with a list of imagecollections. I am not sure how to save on my drive all the images of each imagecollections in the list.

var coll = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG').select('avg_rad');

var geometry = ee.FeatureCollection("users/gg/gadm");

// loop over features and each image of
var loop = function(image){
 var output = geometry.map(function(geom){
 // Clip the image to the polygon geometry
    var ic = image.clip(geom);
    return ic;
})
  return output
};

var outputd = coll.map(loop)

var listOfImages = outputd.toList(outputd.size());

I am looking for a method to clip all the images in an ImageCollection through all the features of a vector (world borders), and then save the resulting tifs in my Google Drive.

So far I wrote this script, which does not work but it gives an idea of what I would like to do. A part for looping over the save with the corresponding filename is missing, as I am not sure how to write it.

var coll = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG').select('avg_rad');
var geometry = ee.FeatureCollection("users/gg/gadm");

var loop = function(image, feature){
    var collection_roi = image.clip(feature);

  // missing part to save each output to drive

    }

var stacked = loop(coll, geometry);

I am looking for a method to clip all the images in an ImageCollection through all the features of a vector (world borders), and then save the resulting tifs in my Google Drive.

So far I wrote this script, which does not work but it gives an idea of what I would like to do. A part for looping over the save with the corresponding filename is missing, as I am not sure how to write it.

var coll = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG').select('avg_rad');
var geometry = ee.FeatureCollection("users/gg/gadm");

var loop = function(image, feature){
    var collection_roi = image.clip(feature);

  // missing part to save each output to drive

    }

var stacked = loop(coll, geometry);

Edit:

Using the following code I did manage to create two-argument loop. However, I end up with a list of imagecollections. I am not sure how to save on my drive all the images of each imagecollections in the list.

var coll = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG').select('avg_rad');

var geometry = ee.FeatureCollection("users/gg/gadm");

// loop over features and each image of
var loop = function(image){
 var output = geometry.map(function(geom){
 // Clip the image to the polygon geometry
    var ic = image.clip(geom);
    return ic;
})
  return output
};

var outputd = coll.map(loop)

var listOfImages = outputd.toList(outputd.size());
Source Link
Jackk
  • 533
  • 4
  • 20

Loop clipping Imagecollection by features of a vector in Earth Engine

I am looking for a method to clip all the images in an ImageCollection through all the features of a vector (world borders), and then save the resulting tifs in my Google Drive.

So far I wrote this script, which does not work but it gives an idea of what I would like to do. A part for looping over the save with the corresponding filename is missing, as I am not sure how to write it.

var coll = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMSLCFG').select('avg_rad');
var geometry = ee.FeatureCollection("users/gg/gadm");

var loop = function(image, feature){
    var collection_roi = image.clip(feature);

  // missing part to save each output to drive

    }

var stacked = loop(coll, geometry);