Skip to content

Commit

Permalink
add distance legend to static maps
Browse files Browse the repository at this point in the history
  • Loading branch information
RWParsons committed Jun 29, 2024
1 parent 5bc22d9 commit 0e04bbd
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 15 deletions.
45 changes: 43 additions & 2 deletions R/vis-plotting-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ get_plotting_utils <- function() {
)

out_dpi <- 600

add_common_plot_features <- function(gg,
theme = map_theme,
x_limits = c(135, 158),
Expand All @@ -34,7 +34,48 @@ get_plotting_utils <- function() {
if (add_dots_for_cities) {
gg <- gg + geom_point(data = cities_data, aes(x = x, y = y))
}
gg

scale_legend <- list(
y_bar = -29.4,
y_text = -30,
x_min = 147.69529500846323,
x_max = 152.85606381166014,
label_text = c("0", "500km")
)

d_rect <- bind_rows(
c(#name = "full bar",
ymin = scale_legend$y_bar-0.1,
ymax = scale_legend$y_bar,
xmin = scale_legend$x_min,
xmax = scale_legend$x_max),

c(#name = "tick_min",
ymin = scale_legend$y_bar-0.2,
ymax = scale_legend$y_bar+0.1,
xmin = scale_legend$x_min,
xmax = scale_legend$x_min-0.1),
c(#name = "tick_min",
ymin = scale_legend$y_bar-0.2,
ymax = scale_legend$y_bar+0.1,
xmin = scale_legend$x_max,
xmax = scale_legend$x_max-0.1)

)

gg +
geom_rect(
data = d_rect, aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax)
) +
geom_text(
data = tibble(
x = c(scale_legend$x_min, scale_legend$x_max),
y = scale_legend$y_text,
text = scale_legend$label_text
),
aes(x = x, y = y, label = text), size = text_size
)

}

other_cities <- data.frame(
Expand Down
27 changes: 14 additions & 13 deletions _targets/meta/meta
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name|type|data|command|depend|seed|path|time|size|bytes|format|repository|iteration|parent|children|seconds|warnings|error
.Random.seed|object|fadc815739e4289f|||||||||||||||
acute_times_file|stem|78628a02c2414b53|fe7e07c76de81ef1|ef46db3751d8e999|447937573|data/Qld_towns_RSQ pathways.xlsx|t19726.86148581s|3f717709e0e1e4d8|104863|file|local|vector|||0.719||
aggregate_kriging_model_to_ASGS|function|1f7585aeb5e5b0e0|||||||||||||||
app_data_dir|object|21851952ded014e0|||||||||||||||
Expand Down Expand Up @@ -96,7 +97,7 @@ get_island_times|function|196ef6db78f9ade7|||||||||||||||
get_iTRAQI_index|function|905c50818f01ef90|||||||||||||||
get_iTRAQI_vis_objs|function|55be0d131ff36527|||||||||||||||
get_new_tt_names|function|f8cd4e5a5bc1684e|||||||||||||||
get_plotting_utils|function|da620ec0077e1b74|||||||||||||||
get_plotting_utils|function|81a5b2a6efb8e4a3|||||||||||||||
get_popup_glue|function|b37f2d473c1aaef0|||||||||||||||
get_remoteness_data|function|f8cd09c404177df6|||||||||||||||
get_seifa_data|function|45503abb62e64271|||||||||||||||
Expand All @@ -106,26 +107,26 @@ get_vis_datasets|function|6edfe006b94a3520|||||||||||||||
gg|function|9eb4e57db553eb17|||||||||||||||
gold_locs|object|66c403e3c86cdcfb|||||||||||||||
index_palette_table|stem|debc7de85244be73|a8df915eafb52551|1f7f2e0ed987beba|1831416846||t19889.2404555814s|237f91a00ac3de41|125|rds|local|vector|||4.375||
inset_maps|stem|f51dffb7c099ecf5|ab623e80ec6aa06a|b6cad3025509a447|1618372214||t19891.2274880081s|97f5d5ebb4412369|161|rds|local|vector|||3.438||
inset_maps|stem|f51dffb7c099ecf5|ab623e80ec6aa06a|1bb73c7caa0215db|1618372214||t19903.1730235872s|97f5d5ebb4412369|161|rds|local|vector|||6.672||
iTRAQI_acute_continuous_map|stem|8918cde785e5e4a6|4746fe8c9f8065d2|6a2b743cfbd45f86|29494645||t19805.2445014188s|ae3ca543e47cf4fd|166|rds|local|vector|||3.078||
iTRAQI_acute_maps|stem|8918cde785e5e4a6|4746fe8c9f8065d2|7756f1d6c4912088|206967308||t19889.2406048891s|ae3ca543e47cf4fd|166|rds|local|vector|||3.984||
iTRAQI_acute_maps|stem|8918cde785e5e4a6|4746fe8c9f8065d2|b346b3d3d8cb01f2|206967308||t19903.1731006489s|ae3ca543e47cf4fd|166|rds|local|vector|||13.406||
iTRAQI_index_counts_tbl|stem|a743647a79bd692b|d57bd319170d08e2|cd910488a7222ea4|1128743655||t19806.1611449963s|22b4442571f78ea6|657|rds|local|vector|||0.813||
iTRAQI_legends|stem|f653617587a60336|2eb810a937c63cee|3f0dbf5dfdcc16a4|-1228347186||t19889.2499307867s|af2f698bb96276c8|148|rds|local|vector|||3.547||
iTRAQI_legends|stem|f653617587a60336|2eb810a937c63cee|af1027980d51b3c8|-1228347186||t19903.1729498498s|af2f698bb96276c8|148|rds|local|vector|||2.344||
itraqi_list|stem|52e26d87581372b8|b0bc70d7b56caee2|7d885c613f99a996|-1855879146||t19889.2400875673s|22357292cb71aa7e|25450950|rds|local|vector|||2.328||
iTRAQI_rehab_maps|stem|e1261ccb6bf56ab6|fd02f3040beca726|6700e89c3189f5f1|140306304||t19889.2405041936s|3c9f22cdd675fcde|167|rds|local|vector|||7||
iTRAQI_sa1_map|stem|4919f2c5defb5a00|2303afe4478a8ce8|85694551c490ac43|-505862102||t19889.259557422s|24d52ebf1535bba2|123|rds|local|vector|||5.875||
iTRAQI_sa2_map|stem|923091d6dba5c13d|b1c883ef38a95d1f|44324981a276d9d0|-544962212||t19889.2595154927s|24d52ebf1535bba2|123|rds|local|vector|||2.297||
iTRAQI_rehab_maps|stem|e1261ccb6bf56ab6|fd02f3040beca726|f1f8f64df463b4c7|140306304||t19903.1730223006s|3c9f22cdd675fcde|167|rds|local|vector|||17.109||
iTRAQI_sa1_map|stem|4919f2c5defb5a00|2303afe4478a8ce8|e3129c174e430087|-505862102||t19903.1730516764s|24d52ebf1535bba2|123|rds|local|vector|||6.578||
iTRAQI_sa2_map|stem|923091d6dba5c13d|b1c883ef38a95d1f|9c15745c5889ceac|-544962212||t19903.1728397985s|24d52ebf1535bba2|123|rds|local|vector|||6.203||
iTRAQI_tables|stem|dbe30ae6c7af123c|d57bd319170d08e2|624f07f5e21b9c64|-130480019||t19889.2405378269s|a2c8acb31b0e29cd|806|rds|local|vector|||1.719||
l_all_drive_times|stem|863290ab751782f0|322c9834645b4160|7cdfb0cf9ae7937a|1979637785||t19727.699503603s|19a7a986c137792d|69482|rds|local|vector|||0.625||
l_itraqi_breaks|stem|1c29f7ad4e7e585f|321d97320e85dc90|ef46db3751d8e999|-472980907||t19866.4660676659s|094cdf8ee71e1e88|135|rds|local|vector|||1.828||
l_remoteness_dlist|stem|ad4ab47fbe2b0197|7505d2c62235815e|932803aac5e694ca|1034374804||t19889.2775152609s|53a8cbd8575b5b11|118236|rds|local|vector|||8.969||
l_seifa_dlist|stem|4caf067195ec9610|b4bdfccb4b029dcc|6a0be32752324e48|-1224354568||t19889.2869973714s|ea96ca5dc2f2dc83|1185506|rds|local|vector|||7.797|Expecting numeric in A55036 R55036C1 got Commonwealth of Australia 2018. Expecting numeric in K2187 R2187C11 got NA. Expecting numeric in L2187 R2187C12 got NA. Expecting numeric in M2187 R2187C13 got NA. Expecting numeric in K2188 R2188C11 got NA. Expecting numeric in L2188 R2188C12 got NA. Expecting numeric in M2188 R2188C13 got NA. Expecting numeric in K2189 R2189C11 got NA. Expecting numeric in L2189 R2189C12 got NA. Expecting numeric in M2189 R2189C13 got NA. Expecting numeric in K2190 R2190C11 got NA. Expecting numeric in L2190 R2190C12 got NA. Expecting numeric in M2190 R2190C13 got NA. Expecting numeric in A2192 R2192C1 got Commonwealth of Australia 2018. Expecting numeric in A56319 R56319C1 got Commonwealth of Australia 2013. Expecting numeric in K52574 R52574C11 got NA. Expecting numeric in L52574 R52574C12 got NA. Expecting numeric in K52575 R52575C11 got NA. Expecting numeric in L52575 R52575C12 got NA. Expecting numeric in K52576 R52576C11 got NA. Expecting numeric in L52576 R52576C12 got NA. Expecting numeric in K52577 R52577C11 got NA. Expecting numeric in L52577 R52577C12 got NA. Expecting numeric in K52578 R52578C11 got NA. Expecting numeric in L52578 R52578C12 got NA. Expecting numeric in K52579 R52579C11 got NA. Expecting numeric in L52579 R52579C12 got NA. Expecting numeric in K52580 R52580C11 got NA. Expecting numeric in L52580 R52580C12 got NA. Expecting numeric in A52583 R52583C1 got Commonwealth of Australia 2013. Detected an unexpected manytomany relationship between x and y.ℹ Row 70 of x matches multiple rows in y.ℹ Row 56312 of y matches multiple rows in x.ℹ If a manytomany relationship is expected, set relationship manytomany to silence this warning.. There were 2 warnings in mutate.The first warning wasℹ In argument acrossall_ofcdecile, percentile, as.numeric.Caused by warning|
l_travel_times|stem|89633cd7b43debad|8d7b12920e0335bc|5c9b399301d1371f|880071042||t19745.2668232455s|61234cae4c0aeef5|70237|rds|local|vector|||0.094||
major_regional_services_map|stem|89641fbb78f90ee1|5ee6004191178fd8|3ccad96dd59b5c64|-1777432472||t19889.202764684s|6935d04907feb3d2|146|rds|local|vector|||0.531|Removed 1 rows containing missing values geom_point.|
major_regional_services_map|stem|89641fbb78f90ee1|5ee6004191178fd8|bcb999d74e081fc0|-1777432472||t19903.1729206598s|6935d04907feb3d2|146|rds|local|vector|||3.219|Removed 1 rows containing missing values geom_point.|
make_acute_maps|function|0621d7dcc6064b92|||||||||||||||
make_continuous_acute_map|function|269bdce1a46702cb|||||||||||||||
make_download_file|function|20199cab48c460c9|||||||||||||||
make_inset_maps|function|71eac8c8387d0429|||||||||||||||
make_inset_maps|function|65f2e88a2983297b|||||||||||||||
make_itraqi_counts_tbls|function|e90bf4a578a63fbe|||||||||||||||
make_itraqi_sa1_map|function|00047f325babb639|||||||||||||||
make_itraqi_sa2_map|function|e7a0e1765ea8c8b0|||||||||||||||
Expand All @@ -141,9 +142,9 @@ output_dir|object|84f147b697db2e10|||||||||||||||
palette_file|stem|937d241336311220|04a82023e2aa5b65|ef46db3751d8e999|2139255348||t19805.2272778607s|887021b347b02e8f|100|rds|local|vector|||1.313||
partition_pnts|function|160bf8bcef341dc5|||||||||||||||
platinum_locs|object|aaa08b5f88f3a54f|||||||||||||||
plotting_utils|stem|82bbaf6ed7bdac52|d44d71bb5e91cb20|6f3c96109f29814f|-2141552691||t19804.2970754549s|710edb2d9dc3ce4e|9720|rds|local|vector|||1.235||
plotting_utils|stem|1285dddc58cca9fc|d44d71bb5e91cb20|be61813c43367bd5|-2141552691||t19903.1726920775s|297863542134db09|17535|rds|local|vector|||1.719||
qas_locations_file|stem|47d8b576de70ef8e|fd3582224bc61473|ef46db3751d8e999|718353251|data/inputs-for-visualisations/qas_locations.csv|t19234.2007883874s|b2dcb5cf37156678|10479|file|local|vector|||1.328||
qas_map|stem|e69241543175c797|eea5e9f0030edc9d|b8f11e86d3b46c2f|61823707||t19889.2025872806s|6aac70ce59868a33|131|rds|local|vector|||3.984||
qas_map|stem|e69241543175c797|eea5e9f0030edc9d|2f97326512431dd9|61823707||t19903.1728739566s|6aac70ce59868a33|131|rds|local|vector|||5.609||
qld_locations_file|stem|371950c86cc87bec|1ec6722829c44405|ef46db3751d8e999|1094260305|data/QLDLocations3422.csv|t19409.0793635134s|8e55589b30e156b7|15655|file|local|vector|||0.704||
quintile_from_decile|function|bc270d6e6e422eb2|||||||||||||||
ra_scale_to_text|function|c1acc9ff04332e8b|||||||||||||||
Expand All @@ -159,7 +160,7 @@ remoteness_files_files|stem|f4657ed37a25cf40|f5ca3075331905f3|ef46db3751d8e999|-
remove_empty_polygons|function|6046100d98ed864e|||||||||||||||
rename_travel_time_df|function|82572c667aa9ceb3|||||||||||||||
rsq_locations_file|stem|72685425b2fb4cb6|7c2c0922575a2b28|ef46db3751d8e999|-3892719|data/inputs-for-visualisations/rsq_locations.csv|t19221.9976706623s|17fd65357607abf9|576|file|local|vector|||1.297||
rsq_maps|stem|39134de7027ce028|765ca2014d1ef285|6347a1a61bc35134|1296509518||t19889.2452751311s|ce9b4a225e799bab|165|rds|local|vector|||2.687||
rsq_maps|stem|39134de7027ce028|765ca2014d1ef285|58b7d15875ca166d|1296509518||t19903.1729516908s|ce9b4a225e799bab|165|rds|local|vector|||9.312||
save_app_markers|function|c936c4cb9c53573d|||||||||||||||
save_app_palette|function|5a64a397d94773ca|||||||||||||||
save_app_scale_fxs|function|4f0852cf0addbd8c|||||||||||||||
Expand All @@ -177,5 +178,5 @@ seifa_text_to_value|function|1b54a5c209cba897|||||||||||||||
silver_locs|object|fc5aaa3d2a561f0c|||||||||||||||
tbl_to_raster|function|bf64572f21350623|||||||||||||||
template_files|stem|751da96a4f79949e|b6c543b3df6e354c|ef46db3751d8e999|-678564935||t19784.2317935203s|f3963c450082b208|143|rds|local|vector|||0.969||
town_locations_map|stem|b21775e38d319929|90827edbdeee3d4d|e0db0e45d8f7d1fd|1832630206||t19889.2026917528s|083ed7cd5fdca87c|132|rds|local|vector|||0.484||
town_locations_map|stem|b21775e38d319929|90827edbdeee3d4d|9a0f6dd429557f3f|1832630206||t19903.1728811896s|083ed7cd5fdca87c|132|rds|local|vector|||5.688||
vis_shapes|stem|1489ae53bc8c594c|eaa9a3aa42a2faf8|d07315f27d3e06e6|-2019822877||t19889.2004713227s|2e75bda9644f9d11|5461037|rds|local|vector|||0.813||
118 changes: 118 additions & 0 deletions app/sandpit.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
library(rdeck)
library(dplyr)
library(sf)
library(leaflet)

pk <- "pk.eyJ1IjoicmV4d3AiLCJhIjoiY2x3bGJraW5xMGFsNDJrcGdqeWZmOTl2NiJ9.Q7FfS7c2JnQSSUzcVj8mnA"
sk <- "sk.eyJ1IjoicmV4d3AiLCJhIjoiY2x3cmV6d2ppMDAyMDJqb2ZlaGx4MDVtaCJ9.4BMMrGUN8YIuKkUqcyKD3w"
options(rdeck.mapbox_access_token = pk)

pal <- function(x) {
sample(c("#ffffff", "#000fff"), size = length(x), replace = TRUE)
}

sa1s_qld <- strayr::read_absmap("sa12021") |>
st_transform(4326) |>
filter(state_name_2021 == "Queensland") |>
mutate(sa1_code_2021 = as.numeric(sa1_code_2021))

m_poly <- sa1s_qld |>
filter(sa1_code_2021 == "30805153502") |>
st_cast("POLYGON")

leaflet() |>
addTiles() |>
leafgl::addGlPolygons(data = m_poly)


leaflet() |>
addTiles() |>
leafgl::addGlPolygons(data = sa1s_qld)



leaflet() |>
addTiles() |>
addPolygons(data = sa1s_qld, label = sa1s_qld$sa1_code_2021)



rdeck(
initial_bounds = st_bbox(sa1s_qld)
) |>
add_polygon_layer(
data = rename(sa1s_qld, polygon = geometry),
get_fill_color = scale_color_linear(sa1_code_2021, palette = pal),
line_width_min_pixels = 0.1,
line_width_max_pixels = 1,
line_width_scale = 2,
get_line_color = "#ffffff"
)



library(rdeck)
library(shiny)
shinyApp(
ui = fillPage(
rdeckOutput("map", height = "100%"),
),
server = function(input, output) {
output$map <- renderRdeck(
rdeck(
map_style = mapbox_dark(),
layer_selector = TRUE,
initial_bounds = st_bbox(sa1s_qld)
) |>
add_mvt_layer(
id = "test",
data = tile_json("mapbox.mapbox-streets-v8"),
# pickable = TRUE, tooltip = TRUE,
get_text = rlang::sym("name"),
get_fill_color = "#FFFFFFFF",
point_type = "text"
) #|>
# add_polygon_layer(
# data = rename(sa1s_qld, polygon = geometry)
# )
)
}
)


library(mapdeck)
key <- "pk.eyJ1IjoicmV4d3AiLCJhIjoiY2x3bGJraW5xMGFsNDJrcGdqeWZmOTl2NiJ9.Q7FfS7c2JnQSSUzcVj8mnA"
set_token(key)

library(geojsonsf)

# sf <- geojsonsf::geojson_sf("https://symbolixau.github.io/data/geojson/SA2_2016_VIC.json")

mapdeck(
style = mapdeck_style("dark")
) %>%
add_polygon(
data = sf,
layer = "polygon_layer",
fill_colour = "SA2_NAME16"
)
#> default

df <- melbourne ## data.frame with encoded polylnies
df$elevation <- sample(100:5000, size = nrow(df))
df$info <- paste0("<b>SA2 - </b><br>", df$SA2_NAME)

mapdeck(
style = mapdeck_style("dark"),
location = c(145, -38),
zoom = 8
) %>%
add_polygon(
data = sa1s_qld
# , polyline = "geometry"
, layer = "polygon_layer",
fill_colour = "SA2_NAME",
elevation = "elevation",
tooltip = "info",
legend = TRUE
)
Binary file modified output/figures/acute-time-continuous.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/acute-time-max-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/acute-time-median-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/acute-time-min-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/iTRAQI-SA1s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/iTRAQI-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/major-and-regional-rehab-services.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/qas_locations.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rehab-services-inset-map-combined.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rehab-time-continuous.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rehab-time-max-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rehab-time-median-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rehab-time-min-SA2s.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rsq-fixed-wing_locations.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rsq-helicopter_and_fixed-wing_locations.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/rsq-helicopter_locations.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added output/figures/test.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/figures/town_locations.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0e04bbd

Please sign in to comment.