I try to convert a javascript google earth engine workflow into python and I face some strange errors. More specifically, I use the below script in order to calculate the mean elevation of a predefined area:
feature_geometry = {
'type': 'MultiPolygon',
'coordinates': [[[
[-113.11777746091163,35.924059850042575],
[-112.43662511716161,35.924059850042575],
[-112.43662511716161, 36.52671462113273],
[-113.11777746091163, 36.52671462113273],
[-113.11777746091163,35.924059850042575]
]]]
}
#Compute the mean elevation in the polygon.
meanDict = srtm.reduceRegion(
reducer= ee.Reducer.mean(),
geometry= feature_geometry,
scale= 90
)
mean = meanDict.get('elevation');
print(mean)
When I execute the above, I get back a dictionary like the one below:
ee.ComputedObject({
"type": "Invocation",
"arguments": {
"dictionary": {
"type": "Invocation",
"arguments": {
"image": {
"type": "Invocation",
"arguments": {
"id": "CGIAR/SRTM90_V4"
},
"functionName": "Image.load"
},
"reducer": {
"type": "Invocation",
"arguments": {},
"functionName": "Reducer.mean"
},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
-113.11777746091163,
35.924059850042575
],
[
-112.43662511716161,
35.924059850042575
],
[
-112.43662511716161,
36.52671462113273
],
[
-113.11777746091163,
36.52671462113273
],
[
-113.11777746091163,
35.924059850042575
]
]
]
]
},
"scale": 90
},
"functionName": "Image.reduceRegion"
},
"key": "elevation"
},
"functionName": "Dictionary.get"
})
Instead the javascript code from this tutorial returns a string value with the result.
What is the correct way to do this in python?