I need to convert my Earth Engine javascript code into the Python API. Most of it works, but when using the following in Python (2.7):

mask = image1.and(image2)

I get:

File "<ipython-input-65-e84ccdaf9093>", line 41
    mask = image1.and(image2)
SyntaxError: invalid syntax

Though it works well with javascript. Any idea how to make this work? More generally, how to know which methods available in GEE docs are/are not implemented in the Python API?


1 Answer 1


and, or and not are reserved words in Python, use And, Or and Not

mask = image1.And(image2)

Your Answer

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

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