Skip to content

Instantly share code, notes, and snippets.

@SakshamInABox
Last active May 8, 2019 10:00
Show Gist options
  • Save SakshamInABox/8aed12018becaa2215243e21f52097be to your computer and use it in GitHub Desktop.
Save SakshamInABox/8aed12018becaa2215243e21f52097be to your computer and use it in GitHub Desktop.
#----Australian Elevation Map----#
#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)
#Printing Digital Elevation Model
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"))
#----The Four Panels----#
#Start PDF Function
pdf("australian_maps.pdf", width=15, height=12)
#Adding North arrow
map_arrow <- north2(ggp = aus.dem, x = 0.72, y = 0.875, symbol = 1)
#Displaying The Two Maps
ggarrange(bound_map, aus.dem, ncol=2, nrow=1)
#Exporting Plot Canvas To PDF.
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment