Skip to content

Instantly share code, notes, and snippets.

@han-tun
Forked from halhen/elevation.R
Created November 4, 2020 16:11
Show Gist options
  • Save han-tun/ac9e548dcc994714d8921ff14979294b to your computer and use it in GitHub Desktop.
Save han-tun/ac9e548dcc994714d8921ff14979294b to your computer and use it in GitHub Desktop.
# Download elevation tif from eg http://www.eea.europa.eu/data-and-maps/data/digital-elevation-model-of-europe
# First, convert elevation tif to a space delimited xyz (lng lat elevation) file
# $ gdal_translate -of XYZ elevation3x3.tif /tmp/file.xyz
df <- read_delim('/tmp/file.xyz', delim=' ', col_names=FALSE)
df %>%
mutate(X3 = na_if(X3, 0)) %>%
ggplot(aes(X1, -X2 + 20 * X3/max(X3, na.rm=TRUE), group=X2)) +
geom_line(size=0.05) +
ggthemes::theme_map() +
coord_equal(0.9)
ggsave('/tmp/map.png', width=10, height=10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment