0

In Google Earth Image I'm trying to download an image using the boundaries of a feature collection using Python.

Working off this example, in 'region' I want to specify a feature collection instead of writing the bounding box. The goal here is to download an image for a specific area (e.g., a country), where I can input the country into "getDownloadUrl" instead of manually specifying the bounding box.

Here's an example trying to download median nighttime lights for Rwanda.

import ee
ee.Initialize()

# Grab Country
countries = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw');
country = countries.filter(ee.Filter.eq('Country', "Rwanda"));

# Grab image, filter by date and country. Take median value across bands
image = ee.ImageCollection('NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG')
image = ee.ImageCollection(image.filterDate("2015-01-01","2015-12-31"))
image = image.reduce(ee.Reducer.median())
image = image.select('avg_rad_median')
image = image.clip(country)

# THIS WORKS. (Note: I just used dummy coordinates for 'region')
path = image.getDownloadUrl({
    'scale': 750,
    'crs': 'EPSG:4326',
    'region': '[[-120, 35], [-119, 35], [-119, 34], [-120, 34]]'
})
print(path)

# THIS DOESN'T WORK
path = image.getDownloadUrl({
    'scale': 750,
    'crs': 'EPSG:4326',
    'region': country
})
print(path)

marked as duplicate by MaryBeth, whyzar, Jochen Schwarze, Community Feb 20 at 14:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.