davemlz / eemont

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

ee.Geometry.Point does not accept varargs after importing eemont #67

Open FeiYao-Edinburgh opened 2 years ago

FeiYao-Edinburgh commented 2 years ago

Hi @davemlz !

I just found a VERY weird behavior in eemont 0.2.5. Before importing the eemont, the following code excerpt works perfectly:

import ee
ee.Initialize()

image = ee.ImageCollection("COPERNICUS/S2_SR").first().set("lon",5.9053, "lat",31.6585)

poi = ee.Geometry.Point([image.getNumber("lon"), image.getNumber("lat")]) # A list of two [x,y] coordinates.
print(poi.getInfo())

poi = ee.Geometry.Point(image.getNumber("lon"), image.getNumber("lat")) # varargs.
print(poi.getInfo())

>>>
{'type': 'Point', 'coordinates': [5.9053, 31.6585]}
{'type': 'Point', 'coordinates': [5.9053, 31.6585]}

However, after importing eemont, the last two sentences will prompts the error of "EEException: Invalid argument specified for ee.Number(): <object object at 0x2b9f90c8ed80>":

import eemont

poi = ee.Geometry.Point([image.getNumber("lon"), image.getNumber("lat")]) # A list of two [x,y] coordinates.
print(poi.getInfo())

poi = ee.Geometry.Point(image.getNumber("lon"), image.getNumber("lat")) # varargs.
print(poi.getInfo())

I spent a couple of hours to identify the root of this weird, hard-to-be-spotted issue, so would like to let you and others know about it, although I am not sure if this still exists in the latest version of the eemont. Also not sure if this issue goes to other functions that accept varargs.

All the best, Fei

davemlz commented 2 years ago

Hi @FeiYao-Edinburgh!

Ok, this is super weird. I've been trying to look for a solution but I have no idea.

I will keep this issue open. Thank you for spotting it!

Best,

David

jencaro19 commented 2 years ago

@davemlz I have also spent the last hours trying to calculate my indices and no matter what I do they don't seem to be added as new bands. the code runs but when i do zonal statistics they are not there! Is the package offline or maybe i am missing something. Thank you image image

Gracias

davemlz commented 2 years ago

Hi @jencaro19!

S2_HARMONIZED is not yet included in the current version of eemont (0.3.4), but it will be in the following days with the upcoming version (0.3.5). Please see https://github.com/davemlz/eemont/issues/68. Thank you!

PD: index() and scale() are deprecated since version 0.3.0, please use spectralIndices() and scaleAndOffset(). See https://eemont.readthedocs.io/en/latest/changelog.html#v0-3-0.

Con gusto! :)

davemlz commented 2 years ago

Hi @jencaro19!

eemont v0.3.5 was just released and now you can try it. It should work! :)

pip install -U eemont