6

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
});

1 Answer 1

10

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

1
  • In case I want to chose (-999999999) as NODATA value, (is the value that ArcGIS reads as NODATA in the function), GEE returns me -1000000000. Do you know why?
    – Juan TB
    Apr 18, 2018 at 13:59

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.