Description Usage Arguments Value Examples
Cut out overlaps in a SpatialPolygons or SpatialPolygonsDataFrame object
1 | tidy_it(x)
|
x |
a SpatialPolygons or SpatialPolygonsDataFrame object |
a SpatialPolygons object with overlaps cut out
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Create an object with two overlapping polygons
"MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)))" %>% readWKT(id="George") -> george
"MULTIPOLYGON (((15 5, 40 10, 41 35, 10 20, 5 10, 15 5)))" %>% readWKT(id="Mildred") -> mildred
rbind(george,mildred) -> p1
c("George","Mildred") -> ID
# Create a color scheme based on IDs of polygons in p1
'olivedrab' %>% adjustcolor(alpha.f=0.5) -> olive
'lemonchiffon' %>% adjustcolor(alpha.f=0.5) -> lemon
c(George=olive,Mildred=lemon) -> cammo
# Useful for the demo
function(x) sapply(slot(x,'polygons'), function(y) slot(y,'ID')) -> get.IDs
par('mfrow') -> old.mf
par(mfrow=c(1,2))
p1 %>% plot(col=cammo[p1 %>% get.IDs]); 'Before' %>% title
p1 %>% tidy_it -> p1_tidy
p1_tidy %>% plot(col=cammo[p1_tidy %>% get.IDs]); 'After' %>% title
par(mfrow=old.mf)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.