ee.FeatureCollection.randomPoints

สร้างจุดแบบสุ่มอย่างสม่ำเสมอในเรขาคณิตที่ระบุ หากเรขาคณิตเป็นแบบ 2 มิติ (รูปหลายเหลี่ยมหรือหลายรูปหลายเหลี่ยม) จุดที่แสดงผลจะกระจายอย่างสม่ำเสมอในภูมิภาคหนึ่งๆ ของทรงกลม หากเรขาคณิตเป็นแบบ 1 มิติ (เส้นสตริง) ระบบจะปักจุดที่แสดงผลตามขอบของเรขาคณิตอย่างสม่ำเสมอ หากเรขาคณิตมีขนาด 0 (จุด) ระบบจะสุ่มตัวอย่างจุดที่แสดงผลจากจุดอินพุตอย่างสม่ำเสมอ หากระบุรูปทรงหลายรูปที่มีมิติข้อมูลแบบผสม ระบบจะสุ่มตัวอย่างจุดจากรูปทรงคอมโพเนนต์ที่มีมิติข้อมูลสูงสุด

การใช้งานการคืนสินค้า
ee.FeatureCollection.randomPoints(region, points, seed, maxError)FeatureCollection
อาร์กิวเมนต์ประเภทรายละเอียด
regionเรขาคณิตภูมิภาคที่จะสร้างคะแนน
pointsจํานวนเต็ม ค่าเริ่มต้น: 1000จำนวนคะแนนที่จะสร้าง
seedยาว ค่าเริ่มต้น: 0เมล็ดสําหรับโปรแกรมสร้างตัวเลขสุ่ม
maxErrorErrorMargin (ไม่บังคับ)ปริมาณข้อผิดพลาดสูงสุดที่ยอมรับได้เมื่อทำการฉายภาพใหม่ที่จำเป็น

ตัวอย่าง

เครื่องมือแก้ไขโค้ด (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