davemlz / eemont

A python package that extends Google Earth Engine.
https://eemont.readthedocs.io/
MIT License
407 stars 69 forks source link

Time Series By Region(s) is not working #36

Closed davemlz closed 3 years ago

davemlz commented 3 years ago

eemont: 0.2.2 ee: 0.1.269

---------------------------------------------------------------------------
HttpError                                 Traceback (most recent call last)
~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/data.py in _execute_cloud_call(call, num_retries)
    333   try:
--> 334     return call.execute(num_retries=num_retries)
    335   except googleapiclient.errors.HttpError as e:

~/anaconda3/envs/gee/lib/python3.9/site-packages/googleapiclient/_helpers.py in positional_wrapper(*args, **kwargs)
    133                     logger.warning(message)
--> 134             return wrapped(*args, **kwargs)
    135 

~/anaconda3/envs/gee/lib/python3.9/site-packages/googleapiclient/http.py in execute(self, http, num_retries)
    914         if resp.status >= 300:
--> 915             raise HttpError(resp, content, uri=self.uri)
    916         return self.postproc(resp, content)

HttpError: <HttpError 400 when requesting https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/value:compute?prettyPrint=false&alt=json returned "ValueNode is empty". Details: "ValueNode is empty">

During handling of the above exception, another exception occurred:

EEException                               Traceback (most recent call last)
<ipython-input-7-6b769aefafc5> in <module>
----> 1 ts = S2.getTimeSeriesByRegion(geometry = roi,
      2                                   bands = indices,
      3                                   reducer = reducers,
      4                                   scale = scale)

~/anaconda3/envs/gee/lib/python3.9/site-packages/eemont/imagecollection.py in getTimeSeriesByRegion(self, reducer, bands, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale, dateColumn, dateFormat, naValue)
    249 
    250         collections.append(
--> 251             ee.FeatureCollection(self.map(reduceImageCollectionByRegion))
    252         )
    253 

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/collection.py in map(self, algorithm, opt_dropNulls)
    196     element_type = self.elementType()
    197     with_cast = lambda e: algorithm(element_type(e))
--> 198     return self._cast(apifunction.ApiFunction.call_(
    199         'Collection.map', self, with_cast, opt_dropNulls))
    200 

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/apifunction.py in call_(cls, name, *args, **kwargs)
     79       a recognized return type, the returned value will be cast to that type.
     80     """
---> 81     return cls.lookup(name).call(*args, **kwargs)
     82 
     83   @classmethod

~/anaconda3/envs/gee/lib/python3.9/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):

~/anaconda3/envs/gee/lib/python3.9/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 

~/anaconda3/envs/gee/lib/python3.9/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(

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/__init__.py in _Promote(arg, klass)
    243       else:
    244         args_count = len(inspect.getfullargspec(arg).args)
--> 245       return CustomFunction.create(arg, 'Object', ['Object'] * args_count)
    246     elif isinstance(arg, Encodable):
    247       # An ee.Function or a computed function like the return value of

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/customfunction.py in create(func, return_type, arg_types)
    119         'args': args
    120     }
--> 121     return CustomFunction(signature, func)
    122 
    123   @staticmethod

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/customfunction.py in __init__(self, signature, body)
     41 
     42     # The signature of the function.
---> 43     self._signature = CustomFunction._resolveNamelessArgs(
     44         signature, variables, body)
     45 

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/customfunction.py in _resolveNamelessArgs(signature, variables, body)
    164       return CountNodes(six.itervalues(expression['values']))
    165 
--> 166     serialized_body = serializer.encode(body(*variables), for_cloud_api=True)
    167     base_name = '_MAPPING_VAR_%d_' % CountFunctions(serialized_body)
    168 

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/collection.py in <lambda>(e)
    195     """
    196     element_type = self.elementType()
--> 197     with_cast = lambda e: algorithm(element_type(e))
    198     return self._cast(apifunction.ApiFunction.call_(
    199         'Collection.map', self, with_cast, opt_dropNulls))

~/anaconda3/envs/gee/lib/python3.9/site-packages/eemont/imagecollection.py in reduceImageCollectionByRegion(img)
    244             else:
    245                 date = ee.Date(img.get("system:time_start")).format(dateFormat)
--> 246             return ee.Feature(None, dictionary).set(
    247                 {dateColumn: date, "reducer": reducerName}
    248             )

~/anaconda3/envs/gee/lib/python3.9/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 

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/feature.py in __init__(self, geom, opt_properties)
     53       super(Feature, self).__init__(feature_constructor, {
     54           'geometry': geom,
---> 55           'metadata': opt_properties or None
     56       })
     57     elif isinstance(geom, computedobject.ComputedObject):

~/anaconda3/envs/gee/lib/python3.9/site-packages/eemont/dictionary.py in __len__(self)
     37         Length of the dictionary.
     38     '''
---> 39     return self.size().getInfo()
     40 
     41 

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/computedobject.py in getInfo(self)
     96       The object can evaluate to anything.
     97     """
---> 98     return data.computeValue(self)
     99 
    100   def encode(self, encoder):

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/data.py in computeValue(obj)
    672     The result of evaluating that object on the server.
    673   """
--> 674   return _execute_cloud_call(
    675       _get_cloud_api_resource().projects().value().compute(
    676           body={'expression': serializer.encode(obj, for_cloud_api=True)},

~/anaconda3/envs/gee/lib/python3.9/site-packages/ee/data.py in _execute_cloud_call(call, num_retries)
    334     return call.execute(num_retries=num_retries)
    335   except googleapiclient.errors.HttpError as e:
--> 336     raise _translate_cloud_exception(e)
    337 
    338 

EEException: ValueNode is empty
davemlz commented 3 years ago

Issue solved. Version 0.2.3 was released.