ee.Image.remap

ממפה מערכי קלט לערכי פלט, שמיוצגים על ידי שתי רשימות מקבילות. ערכי קלט שלא נכללים ברשימת הקלט מוגדרים כ-defaultValue אם הוא ניתן, או מוסתרים אם הוא לא ניתן. שימו לב: לפעמים לא תהיה התאמה בין קלט שמכיל ערכים של נקודה צפה לבין ערכים אחרים בגלל שגיאות בדיוק של נקודה צפה.

שימושהחזרות
Image.remap(from, to, defaultValue, bandName)תמונה
ארגומנטסוגפרטים
זה: imageתמונההתמונה שעליה מוחל המיפוי מחדש.
fromרשימהערכי המקור (מספרים או ee.Array). כל הערכים ברשימה הזו ימופו לערך התואם בפרמטר 'to'.
toרשימהערכי היעד (מספרים או ee.Array). הערכים האלה משמשים להחלפת הערכים התואמים בעמודה 'from'. מספר הערכים בשדה הזה צריך להיות זהה למספר הערכים בשדה 'from'.
defaultValueאובייקט, ברירת מחדל: nullערך ברירת המחדל להחלפת ערכים שלא תואמים לערך בפרמטר 'מתוך'. אם לא מציינים ערך, המערכת מסתירה ערכים לא תואמים.
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 Environment.

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