Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Created August 8, 2015 13:36
Show Gist options
  • Save pepijn-devries/287cd66ed2d594373ef0 to your computer and use it in GitHub Desktop.
Save pepijn-devries/287cd66ed2d594373ef0 to your computer and use it in GitHub Desktop.
for (i in 1:length(poly_volcano))
{
temp <- poly_volcano@polygons[[i]]@Polygons
for (j in 1:length(temp))
{
if (length(temp) > 1)
{
for (k in 1:length(temp))
{
if (j != k)
{
pol_main <- temp[[j]]
pol_comp <- temp[[k]]
val <- point.in.polygon(point.x = pol_comp@coords[1,1], point.y = pol_comp@coords[1,2],
pol.x = pol_main@coords[,1], pol.y = pol_main@coords[,2])
if (val == 1)
{
poly_volcano@polygons[[i]]@Polygons[[k]]@hole <- T
poly_volcano@polygons[[i]]@Polygons[[k]]@coords <- poly_volcano@polygons[[i]]@Polygons[[k]]@coords[nrow(poly_volcano@polygons[[i]]@Polygons[[k]]@coords):1,]
}
}
}
}
}
}
png("volcano03.png", 200, 200)
par(oma = c(0,0,0,0), mar = c(0,0,0,0))
plot(poly_volcano, col = terrain.colors(length(poly_volcano)), border = NA)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment