2

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 JavaScript 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 Python, 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?

1 Answer 1

3

Typing help(ee.Filter) in the Python console shows that 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 Python syntax details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.