[GIS] Selecting n-random points within polygon as single feature in Google Earth Engine

google-earth-enginepointrandomselect-by-location

IMPORTS:

var geometry = /* color: #98ff00 */ee.Geometry.Polygon(
    [[[73.85016678395664, 14.304113379426035],
      [73.85016583974448, 14.048667693939866],
      [74.0477686190103, 14.155139129529527]]]);

CODE:

var fg_points = ee.Feature(geometry);

I thought if the geometry is given as a feature it will select all points in that polygon but it isn't.

How to select some n number of Random Points within a polygon as a single feature in Google Earth Engine?

Best Answer

I have got the answer. If anyone did try the question and didn't get it. Here's the solution.

var fg_points = ee.FeatureCollection.randomPoints(geometry,n, 0, 10);

Arguments: region (geometry): The region to generate points for. points (n, default: 1000): The number of points to generate. seed (Long, default: 0): A seed for the random number generator. max error (ErrorMargin, optional): The maximum amount of error tolerated when performing any necessary reprojection. Returns: FeatureCollection