Invalid argument for ee.Reducer()
See original GitHub issueI was trying to implement the Statistics of an Image Region
example shown here using the python bindings like so:
image = ee.Image('LANDSAT/LE7_TOA_5YEAR/2008_2012')
region = (ee.Feature(ee.FeatureCollection(
'ft:1Ec8IWsP8asxN-ywSqgXWMuBaxI6pPaeh6hC64lA')
.filter(ee.Filter.eq('G200_REGIO', 'Sierra Nevada Coniferous Forests'))
.first())
)
meanDictionary = (image.reduceRegion(
{
'reducer': ee.Reducer.mean(),
'geometry': region.geometry().getInfo(),
'scale': 30,
'maxPixels': 1e9
}
)
)
print(meanDictionary)
However, I run into the following error:
---------------------------------------------------------------------------
EEException Traceback (most recent call last)
<ipython-input-135-ee40bb553fd6> in <module>
12 'geometry': region.geometry().getInfo(),
13 'scale': 30,
---> 14 'maxPixels': 1e9
15 }
16 )
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/apifunction.py in <lambda>(*args, **kwargs)
201 def MakeBoundFunction(func):
202 # We need the lambda to capture "func" from the enclosing scope.
--> 203 return lambda *args, **kwargs: func.call(*args, **kwargs) # pylint: disable=unnecessary-lambda
204 bound_function = MakeBoundFunction(api_func)
205
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/function.py in call(self, *args, **kwargs)
65 to that type.
66 """
---> 67 return self.apply(self.nameArgs(args, kwargs))
68
69 def apply(self, named_args):
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/function.py in apply(self, named_args)
78 to that type.
79 """
---> 80 result = computedobject.ComputedObject(self, self.promoteArgs(named_args))
81 return Function._promoter(result, self.getReturnType())
82
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/function.py in promoteArgs(self, args)
105 name = spec['name']
106 if name in args:
--> 107 promoted_args[name] = Function._promoter(args[name], spec['type'])
108 elif not spec.get('optional'):
109 raise ee_exception.EEException(
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/__init__.py in _Promote(arg, klass)
261 else:
262 # Client-side cast.
--> 263 return cls(arg)
264 else:
265 return arg
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/computedobject.py in __call__(cls, *args, **kwargs)
30 return args[0]
31 else:
---> 32 return type.__call__(cls, *args, **kwargs)
33
34
~/miniconda3/envs/google_earth_engine/lib/python3.6/site-packages/ee/__init__.py in init(self, *args)
377 raise EEException(
378 'Invalid argument for ee.%s(): %s. Must be a ComputedObject.' %
--> 379 (name, args))
380 else:
381 result = args[0]
EEException: Invalid argument for ee.Reducer(): ({'reducer': <ee.Reducer object at
0x10dce9048>, 'geometry': {'type': 'Polygon', 'coordinates': [[[-121.6945185, 40.9321107],
[-121.7223286, 40.9163108], [-121.7813795, 40.8940183], [-121.80290249999997,
40.8794994], [-121.83342760000004, 40.853044700000005],
...
[-121.65048249999998, 40.9200639], [-121.6557616, 40.9302528], [-121.65774560000001,
40.935650900000006], [-121.6945185, 40.9321107]]]}, 'scale': 30, 'maxPixels':
1000000000.0},). Must be a ComputedObject.
The region geometry is a dictionary with coordinates for a polygon. I couldn’t seem to figure out the issue in looking through the code. Any suggestions would be appreciated.
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Invalid argument specified while applying a function on an ...
toBands(); print (normalized);. However, I got the following error. Invalid argument specified for ee.List(): function normalize(_0) { return ...
Read more >How to convert from Javascript to Python API for ...
In the Python EE API, use Python named argument syntax instead of dictionaries for arguments. elevation_mean = elevation.
Read more >ee.Reducer.firstNonNull - Earth Engine - Google Developers
Returns a Reducer that returns the first of its non-null inputs. Usage, Returns. ee.Reducer.firstNonNull(), Reducer. No arguments.
Read more >Google Earth Engine: Temporal and Spatial Reducers
In Google Earth Engine (GEE), reducers are used to aggregate data over time, ... They belong to the ee. ... Reducer() to all...
Read more >End-to-End Google Earth Engine (Full Course Material)
Reducer.sum() , ee.Reducer.histogram() , ee.Reducer.linearFit() etc.) ... containing null geometry and a property containing the number you want to export.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You don’t call python functions with a dictionary, you use regular python keywords:
image.reduceRegion( reducer= ee.Reducer.mean(), geometry= region.geometry().getInfo(), scale= 30, maxPixels= 1e9 )
On Mon, Apr 22, 2019 at 10:36 PM CarpeFridiem notifications@github.com wrote:
– Noel Gorelick (gorelick@gmail.com)
Do this to print the value: