bye bye fusion tables

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);

ngheAnSurfRefl.jpeg

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;">&#65279;</span>
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