ประกาศ: โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ee.Image.remap
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แมปจากค่าอินพุตไปยังค่าเอาต์พุต ซึ่งแสดงด้วยรายการ 2 รายการที่ขนานกัน ค่าอินพุตที่ไม่ได้รวมอยู่ในรายการอินพุตจะได้รับการตั้งค่าเป็น defaultValue หากมีการระบุ หรือมาสก์หากไม่มีการระบุ โปรดทราบว่าอินพุตที่มีค่าจุดลอยตัวอาจไม่ตรงกันในบางครั้งเนื่องจากข้อผิดพลาดเกี่ยวกับความแม่นยำของจุดลอยตัว
| การใช้งาน | การคืนสินค้า |
|---|
Image.remap(from, to, defaultValue, bandName) | รูปภาพ |
| อาร์กิวเมนต์ | ประเภท | รายละเอียด |
|---|
ดังนี้ image | รูปภาพ | รูปภาพที่จะใช้การแมปใหม่ |
from | รายการ | ค่าแหล่งที่มา (ตัวเลขหรือ ee.Array) ระบบจะแมปค่าทั้งหมดในรายการนี้กับค่าที่สอดคล้องกันใน "to" |
to | รายการ | ค่าปลายทาง (ตัวเลขหรือ ee.Array) ซึ่งใช้เพื่อแทนที่ค่าที่สอดคล้องกันใน "จาก" ต้องมีจำนวนค่าเท่ากับ "จาก" |
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
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 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"]]