I am very new to Google Earth Engine and object based image analysis.
First of all, I am trying to do image segmentation using the SNIC algorithm.
This is my code and I got " Tile error: Output of image computation is too large (12 bands for 3513510 pixels = 321.7 MiB > 80.0 MiB). If this is a reduction, try specifying a larger 'tileScale' parameter." error.
How do I get over it?
I already set the tilescale parameter to 16
var s2 = ee.ImageCollection('COPERNICUS/S2_SR');
var rgbVis = {
min: 0.0,
max: 3000,
bands: ['B4', 'B3', 'B2'],
};
var filtered = s2
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 30))
.filter(ee.Filter.date('2021-08-25', '2021-08-29'))
.filter(ee.Filter.bounds(geometry))
.select('B.*');
var composite = filtered.median().clip(geometry) ;
// Display the input composite.
Map.addLayer(composite, rgbVis, 'image');
///SNIC
var seeds = ee.Algorithms.Image.Segmentation.seedGrid(36);
var snic = ee.Algorithms.Image.Segmentation.SNIC({
image: composite,
compactness: 0.2,
connectivity: 8,
neighborhoodSize: 64,
size: 50,
seeds: seeds,
}).reproject({
crs: 'EPSG:4326',
scale: 10
});
Map.addLayer(snic.randomVisualizer(), null, "snic")
/////vector
var clusters_snic = snic.select("clusters")
var vectors = clusters_snic.reduceToVectors({
geometryType: 'polygon',
reducer: ee.Reducer.countEvery(),
scale: 10,
tileScale: 16,
maxPixels: 1e13,
geometry: geometry,
});
var empty = ee.Image().byte();
var outline = empty.paint({
featureCollection: vectors,
color: 1,
width: 1
});
Map.addLayer(outline, {palette: 'FF0000'}, 'segments');