ee.FeatureCollection.remap

ממפה מחדש את הערך של מאפיין ספציפי באוסף. הפונקציה מקבלת שני מערכים מקבילים וממפה את הערכים שנמצאים באחד מהם לערכים שנמצאים בשני. כל רכיב עם ערך שלא צוין ברשימה הראשונה מושמט מקולקציית הפלט.

שימושהחזרות
FeatureCollection.remap(lookupIn, lookupOut, columnName)FeatureCollection
ארגומנטסוגפרטים
זה: collectionFeatureCollectionהאוסף שרוצים לשנות.
lookupInרשימהערכי מיפוי הקלט. מוגבל למחרוזות ולמספרים שלמים.
lookupOutרשימהערכי המיפוי של הפלט. הגודל שלו צריך להיות זהה לזה של lookupIn.
columnNameמחרוזתהשם של הנכס שרוצים למפות מחדש.

דוגמאות

עורך הקוד (JavaScript)

// Classify features based on a string property.
// The 'nonsense' category gets dropped.
var fc = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([1, 2]), {isTree: 'Tree'}),
  ee.Feature(ee.Geometry.Point([3, 4]), {isTree: 'NotTree'}),
  ee.Feature(ee.Geometry.Point([5, 6]), {isTree: 'nonsense'}),
]);

var trees = fc.remap(['NotTree', 'Tree'], [0, 1], 'isTree');
print('remapped trees', trees);

הגדרת Python

מידע על Python API ועל שימוש ב-geemap לפיתוח אינטראקטיבי מופיע בדף Python Environment.

import ee
import geemap.core as geemap

Colab (Python)

# Classify features based on a string property.
# The 'nonsense' category gets dropped.
fc = ee.FeatureCollection([
    ee.Feature(ee.Geometry.Point([1, 2]), {'isTree': 'Tree'}),
    ee.Feature(ee.Geometry.Point([3, 4]), {'isTree': 'NotTree'}),
    ee.Feature(ee.Geometry.Point([5, 6]), {'isTree': 'nonsense'}),
    ])

trees = fc.remap(['NotTree', 'Tree'], [0, 1], 'isTree')
print('Remapped trees:', trees.getInfo())