I am using python api of google earth engine to create NDVI raster. Now I want to export the raster in my google drive. But during exporting it is giving the following error:
ee.featurecollection.FeatureCollection object at 0x03D29EF0> is not JSON serializable
I am using the following piece of code for the entire work
import datetime
import ee
import ee.mapclient
import json
from ee.batch import Export
ee.Initialize()
boundary = ee.FeatureCollection('ft:1rbhNtC1TqDBvY9Rt2BZR-DjhpIPuC3nU5kmz49WW')
image = (ee.ImageCollection('COPERNICUS/S2').
filterBounds(boundary).
filterDate(datetime.datetime(2018,01,24),
datetime.datetime(2018,02,28)).
sort("CLOUD_COVERAGE_ASSESMENT").
limit(20))
mosaic = image.mosaic();
cloudBitMask = ee.Number(2).pow(10).int();
cirrusBitMask = ee.Number(2).pow(11).int();
def maskS2clouds(image): #(
qa = mosaic.select('QA20');
#// Both flags should be set to zero, indicating clear conditions.
mask = qa.bitwiseAnd(cloudBitMask).eq(0)and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask);
cloudMasked = image.filterBounds(boundary).map(maskS2clouds)
median = cloudMasked.median()
clip = median.clip(boundary)
ndvi = clip.normalizedDifference(['B8', 'B4'])
task_config = {
#'image:': ndvi,
'description': 'PythonExample',
'scale': 30,
'region': boundary
}
task = ee.batch.Export.image(ndvi, 'nd', task_config)
Please help me how I can covert FeatureCollection as json object? My per my understanding from the error I might have to convert the fusion table FeatureCollection into JSON object