ประกาศ: โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ee.FeatureCollection.randomPoints
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างจุดแบบสุ่มอย่างสม่ำเสมอในเรขาคณิตที่ระบุ หากเรขาคณิตเป็นแบบ 2 มิติ (รูปหลายเหลี่ยมหรือหลายรูปหลายเหลี่ยม) จุดที่แสดงผลจะกระจายอย่างสม่ำเสมอในภูมิภาคหนึ่งๆ ของทรงกลม หากเรขาคณิตเป็นแบบ 1 มิติ (เส้นสตริง) ระบบจะปักจุดที่แสดงผลตามขอบของเรขาคณิตอย่างสม่ำเสมอ หากเรขาคณิตมีขนาด 0 (จุด) ระบบจะสุ่มตัวอย่างจุดที่แสดงผลจากจุดอินพุตอย่างสม่ำเสมอ หากระบุรูปทรงหลายรูปที่มีมิติข้อมูลแบบผสม ระบบจะสุ่มตัวอย่างจุดจากรูปทรงคอมโพเนนต์ที่มีมิติข้อมูลสูงสุด
| การใช้งาน | การคืนสินค้า |
|---|
ee.FeatureCollection.randomPoints(region, points, seed, maxError) | FeatureCollection |
| อาร์กิวเมนต์ | ประเภท | รายละเอียด |
|---|
region | เรขาคณิต | ภูมิภาคที่จะสร้างคะแนน |
points | จํานวนเต็ม ค่าเริ่มต้น: 1000 | จำนวนคะแนนที่จะสร้าง |
seed | ยาว ค่าเริ่มต้น: 0 | เมล็ดสําหรับโปรแกรมสร้างตัวเลขสุ่ม |
maxError | ErrorMargin (ไม่บังคับ) | ปริมาณข้อผิดพลาดสูงสุดที่ยอมรับได้เมื่อทำการฉายภาพใหม่ที่จำเป็น |
ตัวอย่าง
เครื่องมือแก้ไขโค้ด (JavaScript)
// An ee.Geometry to constrain the geographic bounds of random points.
var region = ee.Geometry.Rectangle(
{coords: [-113.5, 40.0, -110.2, 41.9], geodesic: false});
// Generate 50 random points with the region.
var randomPoints = ee.FeatureCollection.randomPoints(
{region: region, points: 50, seed: 0, maxError: 1});
print('Random points from within the defined region', randomPoints);
Map.setCenter(-111.802, 40.979, 7);
Map.addLayer(region, {color: 'yellow'}, 'Region');
Map.addLayer(randomPoints, {color: 'black'}, 'Random points');
การตั้งค่า Python
ดูข้อมูลเกี่ยวกับ Python API และการใช้ geemap สําหรับการพัฒนาแบบอินเทอร์แอกทีฟได้ที่หน้า
สภาพแวดล้อม Python
import ee
import geemap.core as geemap
Colab (Python)
# An ee.Geometry to constrain the geographic bounds of random points.
region = ee.Geometry.Rectangle(
coords=[-113.5, 40.0, -110.2, 41.9], proj='EPSG:4326', geodesic=False
)
# Generate 50 random points with the region.
random_points = ee.FeatureCollection.randomPoints(
region=region, points=50, seed=0, maxError=1
)
display('Random points from within the defined region', random_points)
m = geemap.Map()
m.set_center(-111.802, 40.979, 7)
m.add_layer(region, {'color': 'yellow'}, 'Region')
m.add_layer(random_points, {'color': 'black'}, 'Random points')
m
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[],["The `ee.FeatureCollection.randomPoints` function generates a specified number of random points within a given geometry. The points are uniformly distributed within the geometry's area if it's two-dimensional, along its edges if one-dimensional, or sampled from the input points if zero-dimensional. For mixed-dimension multi-geometries, points are drawn from the highest-dimension components. The user defines the `region`, the number of `points`, a random `seed`, and an optional `maxError`.\n"]]