TransWikia.com

GEE: Creating a buffer stratum to improve accuracy

Geographic Information Systems Asked on April 9, 2021

I want to create a buffer (post-)stratum in addition to my other four strata (forest, nonForest, degradation, deforestation), in order to increase the accuracy of the auto-classification. My wish is to re-classifiy pixels into this buffer stratum, if they are both 1) classified in the ‘forest’ or ‘nonForest’ strata and 2) in a 2-pixel (60 meters) radius from a disturbance event (classified as ‘degradation’ or ‘deforestation’). Has anyone an idea how I could do this? Any tips on creating a buffer stratum in general would be very helpful already.
Here the code:

// The results are masked in areas of non change, so first unmask
var unmasked = image.unmask()

// Get each stratum and assign correct label
var forest = unmasked.select('forest_2004').eq(1)
  .and(unmasked.select('dist_1').eq(0))
  
var nonForest = unmasked.select('forest_2004').neq(1)
  .and(unmasked.select('dist_1').eq(0)).remap([1],[2]) 
  
  var magThreshold = 20

var degradation = unmasked.select('post_1').eq(1)
  .or(unmasked.select('mag_1').lte(magThreshold))
  .remap([1],[3])

var deforestation = unmasked.select('post_1').gt(1)
  .or(unmasked.select('mag_1').gt(magThreshold))
  .remap([1],[4])
  
// Combine the strata into a single band image 
var strata = ee.Image.cat([forest,nonForest,degradation,deforestation])
  .selfMask()
  .reduce(ee.Reducer.firstNonNull())

Map.addLayer(strata, {min: 1, max: 4, palette: ['#013220','#e5d8bd','#08e8de','#e80812']}, 'strata')

var attributes = {
  forest: 1,
  nonForest: 2,
  degradation: 3,
  deforestation: 4,
  years: '2004-2020'
}

var geo = image.geometry()
Map.addLayer(geo,{},'geo')

Export.image.toAsset({
  image: strata.toByte().setMulti(attributes),
  scale: 30,
  region: image.geometry(),
  maxPixels: 1e13,
  description: '1501_strata'
})

Following the script in the GEE:
https://code.earthengine.google.com/eaea56da0d7de873b8e4fe11d61ad20a?accept_repo=users%2Fbullocke%2Fcoded

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP