Max Shawabkeh 2403df3657 v0.1.51.
2015-04-22 16:36:30 -07:00

27 lines
693 B
Python

#!/usr/bin/env python
"""Where operator example.
Select the forest classes from the MODIS land cover image and intersect them
with elevations above 1000m.
"""
import ee
import ee.mapclient
ee.Initialize()
ee.mapclient.centerMap(-113.41842, 40.055489, 6)
elev = ee.Image('srtm90_v4')
cover = ee.Image('MCD12Q1/MCD12Q1_005_2001_01_01').select('Land_Cover_Type_1')
blank = ee.Image(0)
# Where (1 <= cover <= 4) and (elev > 1000), set the output to 1.
output = blank.where(
cover.lte(4).And(cover.gte(1)).And(elev.gt(1000)),
1)
# Output contains 0s and 1s. Mask it with itself to get rid of the 0s.
result = output.mask(output)
ee.mapclient.addToMap(result, {'palette': '00AA00'})