ee.List.sequence

สร้างลำดับตัวเลขจากจุดเริ่มต้นถึงจุดสิ้นสุด (รวมทั้ง 2 จุด) โดยเพิ่มขึ้นตามค่าขั้น หรือเพิ่มขึ้นตามจำนวนที่เว้นระยะเท่าๆ กัน หากไม่ได้ระบุ end ระบบจะคำนวณจาก start + step * count ดังนั้นต้องระบุอย่างน้อย 1 รายการจาก end หรือ count

การใช้งานการคืนสินค้า
ee.List.sequence(start, end, step, count)รายการ
อาร์กิวเมนต์ประเภทรายละเอียด
startตัวเลขหมายเลขเริ่มต้น
endตัวเลข ค่าเริ่มต้น: nullหมายเลขสิ้นสุด
stepหมายเลข ค่าเริ่มต้น: 1การเพิ่ม
countจำนวนเต็ม ค่าเริ่มต้น: nullจำนวนการเพิ่ม

ตัวอย่าง

โปรแกรมแก้ไขโค้ด (JavaScript)

print(ee.List.sequence(0, 5));  // [0,1,2,3,4,5]
print(ee.List.sequence(0, 10, 2));  // [0,2,4,6,8,10]
print(ee.List.sequence(0, null, 2, 6));  // [0,2,4,6,8,10]
print(ee.List.sequence(0, null, -2, 6));  // [0,-2,-4,-6,-8,-10]

// Step ignored when present along with count.
print(ee.List.sequence(0, 10, 2, 999));  // 999 elements
print(ee.List.sequence(0, 10, 2, 3));  // [0,5,10]

// Using a dictionary for arguments.
print(ee.List.sequence({start:10, count:3}));  // [10,11,12]
print(ee.List.sequence({start:3, step:2, end:6}));  // [3,5]
// [-1000000000,0,1000000000]
print(ee.List.sequence({start:-1e9, end:1e9, count:3}));

การตั้งค่า Python

ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap เพื่อการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า สภาพแวดล้อม Python

import ee
import geemap.core as geemap

Colab (Python)

print(ee.List.sequence(0, 5).getInfo())  # [0, 1, 2, 3, 4, 5]
print(ee.List.sequence(0, 10, 2).getInfo())  # [0, 2, 4, 6, 8, 10]
print(ee.List.sequence(0, None, 2, 6).getInfo())  # [0, 2, 4, 6, 8, 10]
print(ee.List.sequence(0, None, -2, 6).getInfo())  # [0, -2, -4, -6, -8, -10]

# Step ignored when present along with count.
print(ee.List.sequence(0, 10, 2, 999).getInfo())  # 999 elements
print(ee.List.sequence(0, 10, 2, 3).getInfo())  # [0, 5, 10]

# Using a dictionary for arguments.
print(ee.List.sequence(start=10, count=3).getInfo())  # [10, 11, 12]
print(ee.List.sequence(start=3, step=2, end=6).getInfo())  # [3, 5]
# [-1000000000, 0, 1000000000]
print(ee.List.sequence(start=-1e9, end=1e9, count=3).getInfo())