I've processed a raster layer with pixel values ranging between 1 & 8 (see here). A cursory glance reveals that, there's a good tendency of clustering in different parts of the heterogeneous raster band, occasionally intruded by unwanted unlike pixel values. My goal is to make spatial clusters with the following characteristics-
- Every spatial cluster will represent only one pixel value i.e. all the minor intruding pixel values will be converted to the prominent pixel value surrounding it;
- There can be more than one cluster with the same pixel value, but has to be spatially well-separated;
- The clusters can be of any size &/or shape.
Here you can see a few clustering example zones drawn by hand to show tentatively how I want them to be classified. I have searched the 'raster' package of R, but failed to discover anything relevant. A painstaking solution to such problems is digitizing, which, in many ways, is unprofessional, especially when someone has to deal with similar situations over and over again.