3

I performed object-based methods to calculate a mean (zonal statistics) for connected pixels adapted from this guide: https://developers.google.com/earth-engine/guides/image_objects#label_objects

Here is a sample of the code I used the get that final layer:

var objectBased = changeLayer.select([0], ['change'])

var objectId = objectBased.connectedComponents({
  connectedness: ee.Kernel.plus(2),
  maxSize: 1024});
  
Map.addLayer(objectId.randomVisualizer(), null, 'Objects', false);

test = changeLayerClass.addBands(objectId.select('labels'));

var meanClass = test.reduceConnectedComponents({
  reducer: ee.Reducer.mean(),
  labelBand: 'labels',
  maxSize: 1024
});

Map.addLayer(meanClass, {min:3, max:5, palette:['red', 'yellow']}, 'Mean Class', false)

var disturbanceType = meanClass.select(0).gte(4)

Map.addLayer(disturbanceType, {palette:['red', 'yellow']}, 'disturbance')

Export.image.toAsset({
  image: disturbanceType,
  description: 'objectBasedDisturbanceType',
  scale: 10,
  region: geometry,
  maxPixels:300000000
});

I don't encounter a problem when running the analysis, but when I export the end image. The objects that are large are not exported as the other smaller objects.

Object.Id layer Result of the object-based analysis

Result of the object-based analysis

Result when visualizing the exported image Result when visualizing the exported image

How I can fix this issue?

0

The large objects exceed the maxsize you're specified when the data is processed at a scale of 10m. You don't have this problem while viewing, because you're not viewing it at the full 10m (but you will, if you zoom in).

Your best bet is to export the image at something close to the scale at which you're viewing it.

3
  • Thanks for your answer! Is there a way to force those big objects to split in two so I can export them? if my goal is to ultimately keep that 10m scale.
    – COPEL
    Jan 18 at 13:23
  • Well, you could manually clip them in 1/2 by drawing a geometry on top of them and erasing 1/2 the object, but there's probably a better answer if you can explain the bigger picture of what you're doing and why you're doing it this way. Jan 19 at 14:15
  • I am working on typing forest change across Canada. So red means fire change and yellow harvest change. Manually clipping is not really an option here since I am looking to do this "unsupervised" in part due to the extent of area I am looking at. Maybe object-based typing is not the solution in this case..
    – COPEL
    Jan 21 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.