Last active
May 8, 2019 10:00
-
-
Save SakshamInABox/615ec64bafdbdd334a59d9523e290f5f to your computer and use it in GitHub Desktop.
This file contains 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
#Download Elevation Data (Ensure Working Directory Set) | |
alt.aus <- getData(name = "alt", country = "AU") | |
#Calculating Slope & Aspects | |
terr.aus <- terrain(x = alt.aus[[1]], opt = c("slope", "aspect")) | |
#Computing Hill Shade From Aspect & Slope | |
hill.aus <- hillShade(slope = terr.aus$slope, aspect = terr.aus$aspect) | |
#Area Of Interest (Doesn't Seem To Corespond To LAT LONG ?) | |
aoi <- extent(c(xmin = 165, xmax = 179, ymin = -47.85, ymax = -33)) | |
#Use aoi as reference to crop the hill shade raster | |
hill.aus2 <- crop(x = hill.aus, y = aoi) | |
## Same for the elevations | |
alt.aus2 <- crop(x = alt.aus, y = aoi) | |
## Colour palette for the DEM | |
library(RColorBrewer) | |
RdYlBu <- colorRampPalette(colors = rev(brewer.pal(n = 11, "RdYlBu"))) | |
aus.dem <- ggR(hill.aus) + ggR(alt.aus, geom_raster = T, ggLayer = T, alpha = 0.75, | |
ggObj = T) + | |
scale_fill_gradientn(colours = c("red", "orange", "yellow", "white"), name = "Elevation", | |
na.value = "transparent", limits = c(0, 3000), | |
expand = c(0, 0), | |
guide = guide_colourbar(nbin = 2000, barwidth = 0.5, | |
barheight = 3, | |
title.theme = element_text(size = 7), | |
label.theme = element_text(size = 6.5), | |
draw.ulim = F)) + | |
coord_quickmap() + theme_map() + | |
theme(legend.position = c(0.9, 0.4), | |
legend.background = element_rect(fill = "transparent")) | |
aus.dem | |
## Add North arrow | |
north2(ggp = aus.dem, x = 0.72, y = 0.875, symbol = 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment