ee.Image.not
Stay organized with collections
Save and categorize content based on your preferences.
Returns 0 if the input is non-zero, and 1 otherwise.
Usage | Returns | Image.not() | Image |
Argument | Type | Details | this: value | Image | The image to which the operation is applied. |
Examples
Code Editor (JavaScript)
/**
* Demonstrates the ee.Image.Not method.
*
* This example uses positive integers; non-integer and negative
* values are allowed.
*/
var notZeros = ee.Image(3); // Define an image where all pixels are not zero.
var zeros = notZeros.not(); // Pixels are not zeros, return zeros.
var ones = zeros.not(); // Pixels are zeros, return ones.
print('zeros:', zeros);
print('ones:', ones);
// Display images to the map; explore values using the Inspector.
var visParams = {min: 0, max: 1};
Map.addLayer(notZeros, visParams, 'notZeros');
Map.addLayer(zeros, visParams, 'zeros');
Map.addLayer(ones, visParams, 'ones');
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
Colab (Python)
"""Demonstrates the ee.Image.Not method.
This example uses positive integers; non-integer and negative
values are allowed.
"""
import pprint
import ee
ee.Authenticate()
ee.Initialize()
not_zeros = ee.Image(3) # Define an image where all pixels are not zero.
zeros = not_zeros.Not() # Pixels are not zeros, return zeros.
ones = zeros.Not() # Pixels are zeros, return ones.
print('zeros:')
pprint.pprint(zeros.getInfo())
print('\nones:')
pprint.pprint(ones.getInfo())
# Sample images at a location and print the results.
loc = ee.Geometry.Point(0, 0) # Location to sample image values.
print('not_zeros:', not_zeros.sample(loc, 1).first().get('constant').getInfo())
print('zeros:', zeros.sample(loc, 1).first().get('constant').getInfo())
print('ones:', ones.sample(loc, 1).first().get('constant').getInfo())
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]