0

I want to generate a featureColleciton of random points within a polygon. The following creates a featureCollection of points within my polygon, but they're not randomly distributed. Any ideas what I'm doing incorrectly?

var region = ee.Geometry.Polygon(
                          [[[-1.3290613370078064, 59.92374306512899],
                            [-1.329297371401117, 59.92342045678593],
                            [-1.3284176068442322, 59.92330216627425],
                            [-1.3273661809103943, 59.923323673671376],
                            [-1.327494926943109, 59.92380758642121],
                            [-1.3279669957297302, 59.92433450561166],
                            [-1.33022005130224, 59.92482915682877],
                            [-1.3304346280234314, 59.924377519053714],
                            [-1.3290613370078064, 59.92374306512899]]], null, false);
                            

// create random points
var myPoints = ee.FeatureCollection.randomPoints(region);
Map.centerObject(myPoints);
Map.addLayer(region,{color:"red"},"polygon");
Map.addLayer(myPoints,{},"random points");
Anthony W
  • 1,289
  • 2
  • 15
  • 28

1 Answers1

0

From the Google Earth Engine team - there is a bug. A work around is to add a buffer to the region and effectively clip:

// create random points
var myPoints = ee.FeatureCollection.randomPoints(region.buffer(300), 1000)
Anthony W
  • 1,289
  • 2
  • 15
  • 28