ee.Image.remap

इनपुट वैल्यू को आउटपुट वैल्यू पर मैप करता है. इन्हें दो पैरलल सूचियों के तौर पर दिखाया जाता है. इनपुट सूची में शामिल नहीं की गई किसी भी इनपुट वैल्यू को, defaultValue पर सेट किया जाता है. अगर defaultValue नहीं दिया गया है, तो उसे मास्क कर दिया जाता है. ध्यान दें कि फ़्लोटिंग पॉइंट वैल्यू वाले इनपुट, फ़्लोटिंग पॉइंट की सटीक वैल्यू से जुड़ी गड़बड़ियों की वजह से कभी-कभी मैच नहीं हो पाते.

इस्तेमालरिटर्न
Image.remap(from, to, defaultValue, bandName)इमेज
आर्ग्यूमेंटटाइपविवरण
यह: imageइमेजवह इमेज जिस पर रीमैपिंग लागू की गई है.
fromसूचीसोर्स वैल्यू (संख्याएं या ee.Array). इस सूची में मौजूद सभी वैल्यू को 'to' में मौजूद वैल्यू से मैप किया जाएगा.
toसूचीडेस्टिनेशन वैल्यू (संख्याएं या ee.Array). इनका इस्तेमाल, 'from' में मौजूद वैल्यू को बदलने के लिए किया जाता है. इसमें उतनी ही वैल्यू होनी चाहिए जितनी 'from' में हैं.
defaultValueऑब्जेक्ट, डिफ़ॉल्ट: null'from' एट्रिब्यूट की वैल्यू से मैच न होने वाली वैल्यू को बदलने के लिए डिफ़ॉल्ट वैल्यू. अगर यह विकल्प नहीं चुना जाता है, तो मेल न खाने वाली वैल्यू को मास्क कर दिया जाता है.
bandNameस्ट्रिंग, डिफ़ॉल्ट: nullरीमैप किए जाने वाले बैंड का नाम. अगर यह तय नहीं किया गया है, तो इमेज में मौजूद पहले बैंड का इस्तेमाल किया जाता है.

उदाहरण

कोड एडिटर (JavaScript)

// A land cover image.
var img = ee.Image('ESA/WorldCover/v100/2020');

// A list of pixel values to replace.
var fromList = [10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100];

// A corresponding list of replacement values (10 becomes 1, 20 becomes 2, etc).
var toList =   [ 1,  2,  2,  2,  3,  2,  4,  5,  6,  6,  2];

// Replace pixel values in the image. If the image is multi-band, only the
// remapped band will be returned. The returned band name is "remapped".
// Input image properties are retained in the output image.
var imgRemap = img.remap({
  from: fromList,
  to: toList,
  defaultValue: 0,
  bandName: 'Map'
});

// Display the original and remapped images. Note that similar land cover
// classes in the original image are grouped into aggregate classes by
// from → to value mapping.
Map.addLayer(img, null, 'Original image');
Map.addLayer(imgRemap, {
    min: 1, max: 6,
    palette:'darkgreen, lightgreen, red, white, blue, lightblue'
  }, 'Remapped image');

Python सेटअप करना

Python API और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के बारे में जानकारी पाने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# A land cover image.
img = ee.Image('ESA/WorldCover/v100/2020')

# A list of pixel values to replace.
from_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 95, 100]

# A corresponding list of replacement values (10 becomes 1, 20 becomes 2, etc).
to_list = [1, 2, 2, 2, 3, 2, 4, 5, 6, 6, 2]

# Replace pixel values in the image. If the image is multi-band, only the
# remapped band will be returned. The returned band name is "remapped".
# Input image properties are retained in the output image.
img_remap = img.remap(from_list, to_list, defaultValue=0, bandName='Map')

# Display the original and remapped images. Note that similar land cover
# classes in the original image are grouped into aggregate classes by
# from → to value mapping.
m = geemap.Map()
m.add_layer(img, None, 'Original image')
m.add_layer(
    img_remap,
    {
        'min': 1,
        'max': 6,
        'palette': [
            'darkgreen',
            'lightgreen',
            'red',
            'white',
            'blue',
            'lightblue',
        ],
    },
    'Remapped image',
)
m