1

I am trying to write a script that can output a raster file based on the highest and lowest values ​​found in the list of rasters. It is similar to what r.series does in QGIS-GRASS. How can I do this?

El script es el siguiente:

var table = table.filter(ee.Filter.eq('NOMBRE_DPT', 'CASANARE'));

var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-01-01', '2021-01-15')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                    .filterBounds(table);
var sentinel2 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-01-16', '2021-01-30')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                     .filterBounds(table);
var sentinel3 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-02-01', '2021-02-15')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                     .filterBounds(table);
var sentinel4 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-02-16', '2021-02-28')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                     .filterBounds(table);
                    
var sentinel5 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-03-01', '2021-03-15')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                     .filterBounds(table);
var sentinel6 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-03-16', '2021-03-31')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                     .filterBounds(table);   
var sentinel7 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-04-01', '2021-04-15')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                     .filterBounds(table); 
var sentinel8 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-04-16', '2021-04-30')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                    .filterBounds(table);  
var sentinel9 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-05-01', '2021-05-15')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                    .filterBounds(table);
var sentinel10 = ee.ImageCollection('COPERNICUS/S1_GRD')
                    .filterDate('2021-05-16', '2021-05-31')
                    .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
                    .filter(ee.Filter.eq('instrumentMode', 'IW'))
                    .filter(ee.Filter.or((ee.Filter.eq('orbitProperties_pass', 'ASCENDING'), ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))))
                    .filterBounds(table);
                    
var image1 = sentinel1.select('VH').mean().rename('VH1');
var image2 = sentinel2.select('VH').mean().rename('VH2');
var image3 = sentinel3.select('VH').mean().rename('VH3');
var image4 = sentinel4.select('VH').mean().rename('VH4');
var image5 = sentinel5.select('VH').mean().rename('VH5');
var image6 = sentinel6.select('VH').mean().rename('VH6');
var image7 = sentinel7.select('VH').mean().rename('VH7');
var image8 = sentinel8.select('VH').mean().rename('VH8');
var image9 = sentinel9.select('VH').mean().rename('VH9');
var image10 = sentinel10.select('VH').mean().rename('VH10');

var stacked = image1.addBands([image2,image3,image4,image5,image6,image7,image8,image9,image10]).clip(table);
print(stacked);

var stacked_scaled = stacked.multiply(10).add(350).uint8();
var bands = ['VH9', 'VH1', 'VH4'];
var display = {bands: bands, min: 0, max: 220};
Map.addLayer(stacked_scaled, display, 'stacked');
Map.setCenter(-71.70,4.32,8);

ImageCollection.min()???????

1 Answer 1

1

The easiest way to calculate the minimum and maximum value from a series of images is to cast them into an image collection and then use a reducer to calculate the desired metric. Here is the modified version of your script that should output the desired min and max rasters.

var image1 = sentinel1.select('VH').mean();
var image2 = sentinel2.select('VH').mean();
var image3 = sentinel3.select('VH').mean();
var image4 = sentinel4.select('VH').mean();
var image5 = sentinel5.select('VH').mean();
var image6 = sentinel6.select('VH').mean();
var image7 = sentinel7.select('VH').mean();
var image8 = sentinel8.select('VH').mean();
var image9 = sentinel9.select('VH').mean();
var image10 = sentinel10.select('VH').mean();

// Create image collection from list of images
var stacked = ee.ImageCollection.fromImages([image1,image2,image3,image4,image5,image6,image7,image8,image9,image10]);
// Scale all the images
var stacked_scaled = stacked.map(function(image){
  return ee.Image(image).multiply(10).add(350).uint8();
  });

var min = stacked_scaled.min();
var max = stacked_scaled.max();

Map.addLayer(min, {}, 'min');
Map.addLayer(max, {}, 'max');
3
  • thanks jonathan, I'm new to this google engine and I have trouble understanding the programming language. When entering the code I get the following error, is it because I have to enter each of the images by themselves? min: Tile error: Expected a homogeneous image collection, but an image with incompatible bands was encountered: First image type: 1 bands ([VH1]). Current image type: 1 bands ([VH2]). Image ID: null Some bands might require explicit casts. Aug 2, 2022 at 16:34
  • That error means that the images from which you are trying to create an image collection do not share the same band names; thus, the image collection cannot be created. Notice that in my solution I removed the .rename part when creating the image[0-9] objects, so that all the images have a single band names 'VH'. Aug 2, 2022 at 16:49
  • thank you very much jonathan for the help, it has helped me a lot. Aug 2, 2022 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.