ee.FeatureCollection.randomPoints

Generates points that are uniformly random on the sphere, and within the given region.

UsageReturns
ee.FeatureCollection.randomPoints(region, points, seed, maxError)FeatureCollection
ArgumentTypeDetails
regionGeometryThe region to generate points for.
pointsInteger, default: 1000The number of points to generate.
seedLong, default: 0A seed for the random number generator.
maxErrorErrorMargin, optionalThe maximum amount of error tolerated when performing any necessary reprojection.

Examples

Code Editor (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');