create sample from feature collection

Get the centroid of each feature

 

// import lc feature collection
var lc = ee.FeatureCollection("users/servirmekong/cambodia/Landuse2002")

// import feature collection
var provinces = ee.FeatureCollection("users/servirmekong/countries/KHM_adm1");
// import surface reflectance composite
var composites = ee.ImageCollection("projects/servir-mekong/yearlyComposites");

// filter for province
var province = "Batdâmbâng";

// select province from feature collection
var myProvince = provinces.filter(ee.Filter.eq("NAME_1","Batdâmbâng"));

// filter for aoi
var lc = lc.filterBounds(myProvince);

// print all classes
print(lc.aggregate_histogram("NAME"));

// function to get the centroid
function getCentroid(feat){
return feat.centroid();
}

// filter for paddy rice and get the centroid
var rice = lc.filter(ee.Filter.eq("NAME","Paddy field")).map(getCentroid);

// add the points to the map
Map.addLayer(rice,{},"rice");

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s