I have some points and know how to extract the Landsat data at these points and build and export a training dataset to feed an external classifier. But how can I efficiently and automatically build a small patch of 2-D pixels (say 3x3 neighborhood) around each sample point to build and export a similar training dataset to feed an external convolutional classifier?
Answer
I think what you need is ee.Image.neighborhoodToArray
. I give an example:
var i = ee.Image.random().addBands(ee.Image.random(1)).clip(geometry)
Map.addLayer(i)
var neig = i.neighborhoodToArray(ee.Kernel.square(1))
var training = neig.reduceRegions({
collection:points,
scale: 1000,
reducer: 'first'
})
Map.addLayer(training)
link: https://code.earthengine.google.com/a406f32c989923eae10d73af8b1871be
No comments:
Post a Comment