Skip to content

Instantly share code, notes, and snippets.

@pepijn-devries
Created August 8, 2015 14:22
Show Gist options
  • Save pepijn-devries/39a0746bca93e02d6949 to your computer and use it in GitHub Desktop.
Save pepijn-devries/39a0746bca93e02d6949 to your computer and use it in GitHub Desktop.
ContourLines to SpatialPolygons
#create bounding box to which the final polygons needs to be clipped:
CP <- as(extent(0 + 2/ncol(volcano2), 1 - 2/ncol(volcano2), 0 + 2/nrow(volcano2), 1 - 2/nrow(volcano2)), "SpatialPolygons")
#clip polygons and plot:
final_volcano <- gIntersection(poly_volcano, CP, byid=TRUE)
png("volcano04.png", 200, 200)
par(oma = c(0,0,0,0), mar = c(0,0,0,0))
plot(final_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