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"],[[["\u003cp\u003e\u003ccode\u003eee.FeatureCollection.randomPoints\u003c/code\u003e generates uniformly random points within a specified geometry, such as polygons, linestrings, or points.\u003c/p\u003e\n"],["\u003cp\u003eThe distribution of points varies based on the geometry's dimension: uniform on the surface for polygons, along edges for linestrings, and from input points for point geometries.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes parameters like \u003ccode\u003eregion\u003c/code\u003e (geometry), \u003ccode\u003epoints\u003c/code\u003e (number of points), \u003ccode\u003eseed\u003c/code\u003e (for reproducibility), and \u003ccode\u003emaxError\u003c/code\u003e (for reprojection tolerance).\u003c/p\u003e\n"],["\u003cp\u003eUsers can specify the desired number of random points to generate and provide a seed value for consistent results.\u003c/p\u003e\n"],["\u003cp\u003eIf a mixed-dimension geometry is provided, the function samples points from the highest-dimension component.\u003c/p\u003e\n"]]],["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"],null,["# ee.FeatureCollection.randomPoints\n\nGenerates points that are uniformly random in the given geometry. If the geometry is two-dimensional (polygon or multi-polygon) then the returned points are uniformly distributed on the given region of the sphere. If the geometry is one-dimensional (linestrings), the returned points are interpolated uniformly along the geometry's edges. If the geometry has dimension zero (points), the returned points are sampled uniformly from the input points. If a multi-geometry of mixed dimension is given, points are sampled from the component geometries with the highest dimension.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------------------------------------------------------|-------------------|\n| `ee.FeatureCollection.randomPoints(region, `*points* `, `*seed* `, `*maxError*`)` | FeatureCollection |\n\n| Argument | Type | Details |\n|------------|------------------------|-----------------------------------------------------------------------------------|\n| `region` | Geometry | The region to generate points for. |\n| `points` | Integer, default: 1000 | The number of points to generate. |\n| `seed` | Long, default: 0 | A seed for the random number generator. |\n| `maxError` | ErrorMargin, optional | The maximum amount of error tolerated when performing any necessary reprojection. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// An ee.Geometry to constrain the geographic bounds of random points.\nvar region = ee.Geometry.Rectangle(\n {coords: [-113.5, 40.0, -110.2, 41.9], geodesic: false});\n\n// Generate 50 random points with the region.\nvar randomPoints = ee.FeatureCollection.randomPoints(\n {region: region, points: 50, seed: 0, maxError: 1});\n\nprint('Random points from within the defined region', randomPoints);\nMap.setCenter(-111.802, 40.979, 7);\nMap.addLayer(region, {color: 'yellow'}, 'Region');\nMap.addLayer(randomPoints, {color: 'black'}, 'Random points');\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\n# An ee.Geometry to constrain the geographic bounds of random points.\nregion = ee.Geometry.Rectangle(\n coords=[-113.5, 40.0, -110.2, 41.9], proj='EPSG:4326', geodesic=False\n)\n\n# Generate 50 random points with the region.\nrandom_points = ee.FeatureCollection.randomPoints(\n region=region, points=50, seed=0, maxError=1\n)\n\ndisplay('Random points from within the defined region', random_points)\nm = geemap.Map()\nm.set_center(-111.802, 40.979, 7)\nm.add_layer(region, {'color': 'yellow'}, 'Region')\nm.add_layer(random_points, {'color': 'black'}, 'Random points')\nm\n```"]]