tylere / ee-jupyter-examples

Example Jupyter Notebooks, including ones that use the Earth Engine Python API
Apache License 2.0
87 stars 44 forks source link

Unable to import images reduced by featureCollection #3

Open lieying2016 opened 6 years ago

lieying2016 commented 6 years ago

Hi Tylere, Can you help me with an issue? I am using Jupyter Notebooks with Python 3.

I want to download images in a watershed (I got from a fusion table).

import ee ee.Initialize()

get features of watershed

w3031 = ee.FeatureCollection('users/hutx2309/wsd3031')

get ndvi data with only June and July from 2009 to 2017

ndvi = ee.ImageCollection('MODIS/006/MOD13A2').filterDate('2009-01-01','2017-12-31').select('NDVI') ndvi_mon = ndvi.filter(ee.Filter.calendarRange(2009,2017,'year')) .filter(ee.Filter.calendarRange(6,7,'month'))

download data using watershed feature as a filter using python API

image = ndvi_mon.first() task = ee.batch.Export.image.toDrive(image,description='NDVI',region=w3031,scale=1000, crs='EPSG:4326') task.start()

==========================================================

TypeError: Object of type 'FeatureCollection' is not JSON serializable

I have no idea how to deal with this. Thanks!

lieying2016 commented 6 years ago

Note: Similar code works in GEE code editor. I just do not want to click "Run" button for every task using JavaScript.

lieying2016 commented 6 years ago

It seems that I can export images to google drive now. I extract the coordinates in the feature(w3031) first. Then, I use ee.batch.Export.image.toDrive to export one image.