Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var image = ee.Image(ee.ImageCollection('LANDSAT/LC8_L1T_TOA')
- .filterBounds(roi)
- .filterDate('2015-01-01', '2015-12-31')
- .sort('CLOUD_COVER')
- .first());
- print(image);
- Map.addLayer(image, {bands: ['B4', 'B3', 'B2'], max: 0.3}, 'image_L8');
- var clip = image.clip(table); //cliping image to shapefile
- var newclassified =
- vegetation.merge(water).merge(agri_bare).merge(builtarea);
- print(newclassified);
- var bands = ['B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11'];
- var training = clip.select(bands).sampleRegions({
- collection: newclassified,
- properties: ['landcover'],
- scale: 30
- });
- var classifier = ee.Classifier.cart().train({
- features: training,
- classProperty: 'landcover',
- inputProperties: bands
- });
- var classified = clip.select(bands).classify(classifier);
- Map.centerObject(newclassified, 11);
- Map.addLayer(clip,
- {bands: ['B4', 'B3', 'B2'], max: 0.4},
- 'Landsat image');
- Map.addLayer(classified,
- {min: 1, max: 4, palette: ['green', 'blue', 'yellow', 'red']},
- 'classification');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement