I am trying to use SNIC (Simple Non-Iterative Clustering) for clustering land cover areas using python - Google Earth Engine. I am following OBIA as a guide. However, I am getting this error:
EEException: Unrecognized argument type to convert to an Image: {'image': <ee.image.Image object at 0x7f662b6e48b0>, 'size': 32, 'compactness': 5, 'connectivity': 8, 'neighborhoodSize': 256, 'seeds': <ee.image.Image object at 0x7f662b4b1130>}
Code:
countries = ee.FeatureCollection("USDOS/LSIB_SIMPLE/2017")
canada = countries.filter(ee.Filter.eq("country_na", "Canada"))
img = ee.ImageCollection("COPERNICUS/S2")\
.filterDate('01-01-2020','31-12-2020')\
.filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE',20))\
.filterBounds(canada)\
.median()\
.clip(canada)
seeds = ee.Algorithms.Image.Segmentation.seedGrid(36)
snic = ee.Algorithms.Image.Segmentation.SNIC({
'image': img,
'size': 32,
'compactness': 5,
'connectivity': 8,
'neighborhoodSize':256,
'seeds': seeds
})
Map.addLayer(snic.select('clusters').randomVisualizer(),{}, 'NDVI')
Map
Why is this error popping up?