ee.Image.not

Renvoie 0 si l'entrée est différente de zéro, et 1 dans le cas contraire.

UtilisationRenvoie
Image.not()Image
ArgumentTypeDétails
ceci : valueImageImage à laquelle l'opération est appliquée.

Exemples

Éditeur de code (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');

Configuration de Python

Consultez la page Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap pour le développement interactif.

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())