הודעה: כל הפרויקטים הלא מסחריים שנרשמו לשימוש ב-Earth Engine לפני
15 באפריל 2025 חייבים
לאמת את הזכאות לשימוש לא מסחרי כדי לשמור על הגישה. אם לא תאמתו את החשבון עד 26 בספטמבר 2025, יכול להיות שהגישה שלכם תושעה.
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
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[],["The `Image.remap` function replaces pixel values in an image based on two parallel lists: `from` and `to`. Values in `from` are mapped to corresponding values in `to`. Unmatched values are set to `defaultValue` if provided, otherwise they are masked. The function allows users to specify a `bandName`. It is designed to aggregate similar classes by mapping original values to new values, the remapped band name is \"remapped\".\n"]]