Store your training data as a feature collection
Step 1: export your training data. Store it as a feature collection (link)
var admin = ee.FeatureCollection("users/servirmekong/Vietnam/adm1Shp").filter(ee.Filter.eq("VARNAME_1","Nghe An")); var img = ee.Image(ee.ImageCollection("projects/servir-mekong/yearlyComposites").filterDate("2016-01-01","2016-12-31").first()); Map.addLayer(img.clip(admin),{min:0,max:3000,bands:"red,green,blue"}); var TrainingData = urban.merge(paddyrice).merge(water).merge(crop).merge(forest); var sample = img.sampleRegions({ collection: TrainingData, scale:30, properties:["land_class"], geometries:true, tileScale:16 }); Export.table.toAsset(sample);
Step 2: import to the training data and use it in your machine learning algorithm. (link)
// import fusion table var trainingData = ee.FeatureCollection("users/servirmekong/shapefiles/trainingDataTest"); var region = ee.FeatureCollection("users/servirmekong/Vietnam/adm1Shp").filter(ee.Filter.eq("VARNAME_1","Nghe An")); var img = ee.Image(ee.ImageCollection("projects/servir-mekong/yearlyComposites").filterDate("2016-01-01","2016-12-31").first()); var classifier = ee.Classifier.randomForest(10,0).train(trainingData,"land_class",img.bandNames()); var classification = img.classify(classifier,'Mode').clip(region); /* 0 forest 1 urban 2 rice 3 water 4 crop */ Map.addLayer(classification,{min:0,max:4,palette:"green,red,yellow,blue,orange"},"classified image")<span id="mce_SELREST_start" style="overflow:hidden;line-height:0"></span>
Dear thisearthsite
Google Fusion Tables Turndown (after Dec. 3, 2019). Please help show me how to upload shapefiles as fusion tables and use them in the GEE.
Many thanks,
LikeLike
In contrast, how can i import the training sample as shapefile to GEE. Thank you for your support!
LikeLike