TransWikia.com

Google Earth Engine Python API Filter.or Invalid Snytax

Geographic Information Systems Asked on November 30, 2020

I am trying to filter a MODIS image collection for two date ranges with the Python API of Google Earth Engine, but I’m encountering the following problem.

In the Google Code Editor, I would do something like this:

var modis1 = ee.ImageCollection('MODIS/006/MOD11A1');
var rng1= ee.Filter.date('2019-02-01','2019-06-30');
var rng2 = ee.Filter.date('2020-02-01','2020-06-30')
var rngor = ee.Filter.or(rng1,rng2);
var modisfiltered = modis1.filter(rngor);

And this would work. In Pyhton, instead, the code stops on the ee.Filter.or line because of an "Invalid Syntax" error. Is it because "or" is a reserved keyword in Python? How can I obtain the same result?

Thank you for any help!

One Answer

Ok, that's pretty dumb and it was as easy as typing "help(ee.Filter)" in the Python console. The Python API uses ee.Filter.Or, with a capital "O".

That's the first time that the integrate help function helps me more than a help search though, Google Earth Engine API online documentation is pretty lacking on Pytho syntax details!

Correct answer by Mutewinter on November 30, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP