Last updated: 2022-05-20
Checks: 7 0
Knit directory: myTidyTuesday/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210907)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version 2278db5. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/.Rhistory
Ignored: data/CNHI_Excel_Chart.xlsx
Ignored: data/Chicago.rds
Ignored: data/CommunityTreemap.jpeg
Ignored: data/Community_Roles.jpeg
Ignored: data/SeriesReport-20220414171148_6c3b18.xlsx
Ignored: data/Weekly_Chicago_IL_Regular_Reformulated_Retail_Gasoline_Prices.csv
Ignored: data/YammerDigitalDataScienceMembership.xlsx
Ignored: data/YammerMemberPage.rds
Ignored: data/YammerMembers.rds
Ignored: data/df.rds
Ignored: data/grainstocks.rds
Ignored: data/hike_data.rds
Ignored: data/mfg_shap.rds
Ignored: data/netflixTitles2.rds
Ignored: data/raw_weather.RData
Ignored: data/sample_submission.csv
Ignored: data/shap_int.rds
Ignored: data/test.csv
Ignored: data/train.csv
Ignored: data/us_states.rds
Ignored: data/us_states_hexgrid.geojson
Ignored: data/weatherstats_toronto_daily.csv
Ignored: data/xgboost_fit.rds
Ignored: data/xgboost_fit_full.rds
Untracked files:
Untracked: analysis/2022_May_tabular_playground.Rmd
Untracked: code/YammerReach.R
Untracked: code/chicago.R
Untracked: code/googleCompute.R
Untracked: code/work list batch targets.R
Untracked: environment.yml
Untracked: report.html
Unstaged changes:
Deleted: analysis/2022_02_11_tabular_playground.Rmd
Deleted: analysis/2022_04_18.qmd
Modified: code/_common.R
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown (analysis/2022_05_20.Rmd
) and HTML
(docs/2022_05_20.html
) files. If you’ve configured a remote
Git repository (see ?wflow_git_remote
), click on the
hyperlinks in the table below to view the files as they were in that
past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 2278db5 | opus1993 | 2022-05-20 | Belgium map |
This is a Friday diversion, to work through Milos Popovic’s code and craft a nice looking topographic map of Belgium.
Reference https://github.com/milos-agathon/crisp-topographical-map-with-r
I'm excited to share my new topographic map of Italy🇮🇹 as well as the link to my new tutorial that shows you how to make your own crisp topo maps of any country in the world!
— Milos Popovic (@milos_agathon) May 14, 2022
💡https://t.co/Weo0NcwpBX#tutorial #RStats #DataScience #dataviz #maps #coding pic.twitter.com/QTzYBjmMUJ
First, let’s load the packages:
suppressPackageStartupMessages({
library(elevatr)
library(terra)
library(tidyverse)
library(sf)
library(giscoR)
library(marmap)
})
Second, let’s load the data and a helper function to glue the counts of countries onto the country labels:
#---------
crsLONGLAT <- "+proj=longlat +datum=WGS84 +no_defs"
get_sf <- function(country_sf, country_transformed) {
country_sf <- giscoR::gisco_get_countries(
year = "2016",
epsg = "4326",
resolution = "10",
country = "Belgium"
)
country_transformed <- st_transform(country_sf, crs = crsLONGLAT)
return(country_transformed)
}
country_transformed <- get_sf()
get_elevation_data <- function(country_elevation, country_elevation_df) {
country_elevation <- get_elev_raster(
locations = country_transformed,
z = 10, # Please decrease the z value if you experience R crashing
clip = "locations"
)
country_elevation_df <- as.data.frame(country_elevation, xy = T) %>%
na.omit()
colnames(country_elevation_df)[3] <- "elevation"
return(country_elevation_df)
}
country_elevation_df <- get_elevation_data()
Mosaicing & Projecting
Clipping DEM to locations
Note: Elevation units are in meters.
get_elevation_map <- function(country_map) {
country_map <- ggplot() +
geom_tile(
data = country_elevation_df,
aes(x = x, y = y, fill = elevation)
) +
scale_fill_etopo() +
coord_sf(crs = crsLONGLAT) +
theme_minimal() +
theme(
text = element_text(family = "georg", color = "#22211d"),
axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none",
panel.grid.major = element_line(color = "white", size = 0.2),
panel.grid.minor = element_blank(),
plot.title = element_text(size = 18, color = "grey20", hjust = 1, vjust = -5),
plot.caption = element_text(size = 8, color = "grey70", hjust = .15, vjust = 20),
plot.margin = unit(c(t = 0, r = 0, b = 0, l = 0), "lines"),
plot.background = element_rect(fill = "white", color = NA),
panel.background = element_rect(fill = "white", color = NA),
panel.border = element_blank()
) +
labs(
x = "",
y = NULL,
title = "Topographic map of Belgium",
subtitle = "",
caption = "©2022 @jim_gruman"
)
return(country_map)
}
country_map <- get_elevation_map()
country_map
sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] marmap_1.0.6 giscoR_0.3.1 sf_1.0-7 forcats_0.5.1
[5] stringr_1.4.0 dplyr_1.0.9 purrr_0.3.4 readr_2.1.2
[9] tidyr_1.2.0 tibble_3.1.7 ggplot2_3.3.6 tidyverse_1.3.1
[13] terra_1.5-21 elevatr_0.4.2 workflowr_1.7.0
loaded via a namespace (and not attached):
[1] colorspace_2.0-3 ellipsis_0.3.2 class_7.3-20
[4] rgdal_1.5-32 rprojroot_2.0.3 fs_1.5.2
[7] rstudioapi_0.13 proxy_0.4-26 farver_2.1.0
[10] bit64_4.0.5 fansi_1.0.3 lubridate_1.8.0
[13] xml2_1.3.3 codetools_0.2-18 R.methodsS3_1.8.1
[16] ncdf4_1.19 cachem_1.0.6 knitr_1.39
[19] jsonlite_1.8.0 broom_0.8.0 dbplyr_2.1.1
[22] R.oo_1.24.0 compiler_4.1.3 httr_1.4.3
[25] backports_1.4.1 assertthat_0.2.1 fastmap_1.1.0
[28] cli_3.2.0 later_1.3.0 s2_1.0.7
[31] prettyunits_1.1.1 htmltools_0.5.2 tools_4.1.3
[34] gtable_0.3.0 glue_1.6.2 reshape2_1.4.4
[37] wk_0.6.0 rappdirs_0.3.3 Rcpp_1.0.8.3
[40] cellranger_1.1.0 jquerylib_0.1.4 styler_1.7.0
[43] raster_3.5-15 vctrs_0.4.1 countrycode_1.4.0
[46] progressr_0.10.0 xfun_0.31 ps_1.7.0
[49] rvest_1.0.2 lifecycle_1.0.1 getPass_0.2-2
[52] scales_1.2.0 hms_1.1.1 promises_1.2.0.1
[55] slippymath_0.3.1 rematch2_2.1.2 yaml_2.3.5
[58] curl_4.3.2 memoise_2.0.1 sass_0.4.1
[61] tweetrmd_0.0.9 stringi_1.7.6 RSQLite_2.2.14
[64] highr_0.9 e1071_1.7-9 shape_1.4.6
[67] rlang_1.0.2 pkgconfig_2.0.3 evaluate_0.15
[70] lattice_0.20-45 bit_4.0.4 processx_3.5.3
[73] tidyselect_1.1.2 plyr_1.8.7 magrittr_2.0.3
[76] geojsonsf_2.0.2 R6_2.5.1 generics_0.1.2
[79] DBI_1.1.2 pillar_1.7.0 haven_2.5.0
[82] whisker_0.4 withr_2.5.0 units_0.8-0
[85] sp_1.4-7 modelr_0.1.8 crayon_1.5.1
[88] KernSmooth_2.23-20 utf8_1.2.2 tzdb_0.3.0
[91] rmarkdown_2.14 progress_1.2.2 grid_4.1.3
[94] readxl_1.4.0 blob_1.2.3 callr_3.7.0
[97] git2r_0.30.1 reprex_2.0.1 digest_0.6.29
[100] classInt_0.4-3 adehabitatMA_0.3.14 R.cache_0.15.0
[103] httpuv_1.6.5 R.utils_2.11.0 munsell_0.5.0
[106] bslib_0.3.1