0

I'm trying to export a raster as GeoTIFF from GEE and keep it's min max range (pixel value) so I can import the raster into ArcGIS and check it's min, max, mean and std.dev. in Symbology. My attempt so far can only manage to export the raster layer with a green color but when imported into ArcGIS all min, max, mean and std. dev. is 0. Here is the code I have tried:

var Blueskin =ee.Image('COPERNICUS/S2/20160721T223713_20160722T000334_T59GMK');
var Red=Blueskin.select('B4');
var NIR=Blueskin.select('B8');
var ndvi = NIR.subtract(Red).divide(NIR.add(Red)).rename('NDVI');
var mean = ee.Number(stats.get('NDVI_mean'));
var std = ee.Number(stats.get('NDVI_stdDev'));
//find regions (Ulva) in ndvi has value higher than mean +1SD 
var maskImage = ndvi.updateMask(ndvi.gt(mean.add(std)));
Map.addLayer(maskImage, {palette: 'green'}, 'mask image');
//get Ulva region max min
var stats = maskImage.reduceRegion({
  reducer: ee.Reducer.minMax(),
  bestEffort: true,
});

// Display min and max
print(stats);
//it's a bit confusing here but NDVI_min =maskImage_min according to print I just don't know how to change the name
var NDVI_min = ee.Number(stats.get('NDVI_min'));
var NDVI_max = ee.Number(stats.get('NDVI_max'));
print(NDVI_min);
print(NDVI_max);
var visualization_params =  {min: NDVI_min, max: NDVI_max, palette:'green'};
// Export a cloud-optimized GeoTIFF.
Export.image.toDrive({
  image: maskImage.visualize(visualization_params),
  description: '21072016UNDVI',
  scale: 10,
  region: table,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  }
});

The min and max I set in the visualization_params doesn't seem to work and I can't use ee.Reducer.minMax() as an argument in visualization_params..

2

0

Your Answer

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