Tuesday 30 April 2019

google earth engine - GEE: How to transform masked values (NODATA) to -9999?


How can I transform NoData (masked) values to a value? When the image is mapped, there are a lot of values that are masked and I would like to get a value (-9999) on that masked pixels.


var region = geometry;


// Collect data and filter by total dates

var coll = ee.ImageCollection ("MODIS/006/MOD16A2")
.filterDate('2000-01-01', '2014-12-31')
.filterBounds(region)
.filter(ee.Filter.calendarRange(1,1,'month'));

print (coll)
var modisET = ee.Image('MODIS/006/MOD16A2/2001_01_01')
.select("ET");



var multiply = modisET.multiply(0.1)

var divide = multiply.divide(8)


// Normalize the image and add it to the map.
var rescaled = divide.unitScale(0,1);
var visParams = {min: -1, max: 1};



var reprojected = divide
.unitScale(0, 1)
.reproject('EPSG:4326', null, 500);

Map.addLayer(reprojected)



// Export the image, specifying scale and region.
Export.image.toDrive({

image: reprojected,
description: '2001_01_01',
scale: 500,
region: table
});

Answer



This can be done using the unmask function on your image, which allows you to set a value of your choice for the masked pixels.


.unmask(-9999)

An example script building on your question: https://code.earthengine.google.com/87f1a9d5193c562ff016fd4b13c45720



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...