I would like to assign small polygons nested in larger polygons the same values as those of larger polygons.
In figure 1 you can see the small polygons in raster
format:
and in figure 2 in SpatialPolygons
as individual polygons:
These polygons are results of sorting by k-means, generating raster, and using the rasterFromXYZ
function (code below):
mydata.26.raster <- rasterFromXYZ(as.data.frame(mydata.26.coord[,c("x", "y", "cls_26.cluster")]),res=5, crs=crs)
and then rasterToPolygons
function I was able to separate the polygons (code below):
zona.26.pol<- rasterToPolygons(zona.26.raster$cls_26.cluster,dissolve=TRUE)
zona.26.pol <- disaggregate(zona.26.pol)
Here's zona.26.pol if you want to help It is in .shp format.
And manually I reclassified the polygons and finally added them using the same classes. After manually assigning the values by me, the result that I would like to achieve automatically (creating rules) is in figure 3:
Every help is welcome!