[GIS] Google Earth Engine: undefined value conversion

google-earth-engine

I am using the Google Earth Engine API in Python. I am trying to reconvert undefined (i.e. null) values onto a value of choice. Inspired by a discussion here, my code is as follows:

import ee

ee.Initialize()
c = ee.ImageCollection('MODIS/006/MOD13Q1').filterDate('2003-12-19', '2004-01-19').select('NDVI')
p = ee.Geometry.Point([-8.802372,  41.722677])
data = c.getRegion(p, scale = 1000).getInfo()
print 'data=',data

def filterNull(img):
    ndviU = img.select('NDVI')
    ndviF = ee.Algorithms.If(ee.Algorithms.IsEqual(ndviU, None), -2000, ndviU)
    return img.addBands(ndviF) 

cf = c.map(filterNull)
dataf = cf.getRegion(p, scale = 1000).getInfo()
print 'dataf=',dataf

It doesn't work though, the output indicates no change for the None value.

data= [[u'id', u'longitude', u'latitude', u'time', u'NDVI'], 
       [u'2003_12_19', -8.798998207950714, 41.72225337093118, 1071792000000L, None], 
       [u'2004_01_01', -8.798998207950714, 41.72225337093118, 1072915200000L, 7339], 
       [u'2004_01_17', -8.798998207950714, 41.72225337093118, 1074297600000L, 7090]]
dataf= [[u'id', u'longitude', u'latitude', u'time', u'NDVI', u'NDVI_1'], 
        [u'2003_12_19', -8.798998207950714, 41.72225337093118, 1071792000000L, None, None], 
        [u'2004_01_01', -8.798998207950714, 41.72225337093118, 1072915200000L, 7339, 7339], 
        [u'2004_01_17', -8.798998207950714, 41.72225337093118, 1074297600000L, 7090, 7090]]

Best Answer

Yes, ee.Image.unmask() is used to convert an image's masked values to actual values. To apply to all images in a collection, use ee.ImageCollection.map() to map a function that operates on a single image.