Last active
November 27, 2020 12:22
-
-
Save rCarto/7dfca328e0cd2a3455ba6cf9601c0147 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(sf) | |
library(elevatr) | |
library(raster) | |
library(tanaka) | |
# a polygon of bangalore | |
bangalore <- st_read("export.geojson") | |
elevation <- get_elev_raster(bangalore, z = 10) | |
bangalore_elevation <- trim(mask(elevation, bangalore)) | |
# inspect min and max values | |
summary(bangalore_elevation) | |
# get contours | |
bangalore_contour <- tanaka_contour(bangalore_elevation, | |
breaks = seq(750, 1000, 25)) | |
# define margins and facets | |
par(mfrow = c(1,2), mar = c(0,0,0,0)) | |
# plot raster and contour | |
plot(bangalore_elevation, axes = F, box = FALSE, legend = FALSE) | |
plot(st_geometry(bangalore_contour), add = TRUE, | |
col = NA, border = "grey20", lwd = .5) | |
# plot tanaka | |
tanaka(bangalore_contour, | |
col = hcl.colors(n = nrow(bangalore_contour), | |
palette = "Cividis"), | |
legend.pos = "topright") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment