ee.FeatureCollection.remap

เปลี่ยนค่าของพร็อพเพอร์ตี้ที่เฉพาะเจาะจงในคอลเล็กชัน รับรายการคู่ขนาน 2 รายการและจับคู่ค่าที่พบในรายการหนึ่งกับค่าในอีกรายการหนึ่ง ระบบจะทิ้งองค์ประกอบที่มีค่าไม่ได้ระบุไว้ในรายการแรกออกจากคอลเล็กชันเอาต์พุต

การใช้งานการคืนสินค้า
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

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