Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Automatically reclassify small SpatialPolygons inserted into large SpatialPolygons using R

$
0
0

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:

Raster with small polygons within larger polygons

and in figure 2 in SpatialPolygons as individual polygons: Disaggregated 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:

Reclassified and aggregated final image

Every help is welcome!


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>