Closed gaowudao closed 3 years ago
Hi, @gaowudao!
In the expression of the formula you should use the method as a function itself. The correct form of the formula would be this:
'19.4260 + 9.2603 * (G / R) - 57.9165 * log(R) + 86.9934 * log(G) - 6.4577 * R - 17.6220 * log(B)'
Note that the log()
function is not a method of the band :)
Let me know if it works!
Also, you must define the bands
, short_name
and type
attributes to make it work correctly :)
PD: Another option (if you want) would be adding the index to the Awesome Spectral Indices and then computing it in eemont
by setting online=True
in the spectralIndices()
method! :) Example below:
f1 = ee.Feature(ee.Geometry.Point([120.076432, 30.86733]).buffer(10),{'ID':'A'})
fc = ee.FeatureCollection([f1])
S2 = (ee.ImageCollection('COPERNICUS/S2_SR')
.filterBounds(fc)
.filterDate('2021-04-30','2021-08-30')
.scaleAndOffset()
.spectralIndices(['NDVI','GNDVI','EVI','WD'],online = True))
I'll close the issue with this comment, but please feel free to re-open it if required!
Hello, I have a formula,called "WD", ("formula": "19.4260 + 9.2603 (G / R) - 57.9165 (R.log()) + 86.9934 (G.log()) - 6.4577 R - 17.6220 * (B.log())"), and added it into spectral-indices-dict.json file.
What I did:
f1 = ee.Feature(ee.Geometry.Point([120.076432, 30.86733]).buffer(10),{'ID':'A'})
fc = ee.FeatureCollection([f1])
S2 = (ee.ImageCollection('COPERNICUS/S2_SR') .filterBounds(fc) .filterDate('2021-04-30','2021-08-30')
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 40))
.maskClouds()
.scale() .index(['NDVI','GNDVI','EVI','WD']))
By Regions
ts = S2.getTimeSeriesByRegions(reducer = [ee.Reducer.mean()], collection = fc, bands = ['B2','B3','B4','B5','B6','B7','B8','B8A','WD','MSK_CLDPRB'], scale = 10)
df = geemap.ee_to_pandas(ts, selectors=['B2','B3','B4','B5','B6','B7','B8','B8A','WD','MSK_CLDPRB'])
error Exception: Image.parseExpression: Expression parse error at character 45: '19.4260 + 9.2603 (G / R) - 57.9165 (R.log()) + 86.9934 (G.log()) - 6.4577 R - 17.6220 * (B.log())' ^.