Skip to content

Commit

Permalink
new colors
Browse files Browse the repository at this point in the history
  • Loading branch information
ramarty committed Sep 4, 2024
1 parent 0fd3884 commit 0b26d84
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/gt_load_png_as_traffic_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ gt_load_png_as_traffic_raster <- function(filename,
## Image to hex
rimg <- raster::as.raster(img)

google_colours = c("#63D668", "#FF974D", "#F23C32", "#811F1F")
#google_colours = c("#11D68F", "#FFCF43", "#F24E42", "#A92727")
#google_colours = c("#63D668", "#FF974D", "#F23C32", "#811F1F")
google_colours = c("#11D68F", "#FFCF43", "#F24E42", "#A92727")
google_colours_ff <- paste0(google_colours, "FF")

if(traffic_color_dist_thresh == 0){
Expand Down
1 change: 0 additions & 1 deletion R/gt_make_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ gt_make_html <- function(location,
filename,
google_key){


html_code <- paste0('
<!DOCTYPE html>
<html>
Expand Down
5 changes: 3 additions & 2 deletions make_readme_figures/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ google_key_df <- api_keys_df |>
dplyr::filter(Service == "Google Directions API",
Account == "ramarty@email.wm.edu")
google_key <- google_key_df$Key
google_key <- "AIzaSyCD7419gX2aQF0eufWO1lItGJW-jEcdFYA"

# Test -------------------------------------------------------------------------
gt_make_png(location = c(40.717437418183884, -73.99145764250052),
height = 200,
width = 200,
height = 500,
width = 500,
zoom = 16,
out_filename = paste0("~/Desktop/test123.png"),
google_key = google_key)
Expand Down
39 changes: 39 additions & 0 deletions make_readme_figures/testing_from_source.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#### Packages
library(dplyr)
library(googleway)
library(htmlwidgets)
Expand All @@ -19,9 +20,47 @@ files <- file.path("~", "Documents", "Github", "googletraffic", "R") |>
pattern = "*.R")
for(file_i in files) source(file_i)

#### Key
api_keys_df <- read.csv("~/Dropbox/World Bank/Webscraping/Files for Server/api_keys.csv")

google_key_df <- api_keys_df |>
dplyr::filter(Service == "Google Javascript API",
Account == "robmarty3@gmail.com")
google_key <- google_key_df$Key


# Test -------------------------------------------------------------------------
LAT <- 38.9100357120388
LON <- -77.02695642916511

gt_make_png(location = c(LAT, LON),
height = 500,
width = 500,
zoom = 16,
out_filename = paste0("~/Desktop/test123.png"),
google_key = google_key)

r <- gt_make_raster(location = c(LAT, LON),
height = 200,
width = 200,
zoom = 16,
google_key = google_key)




#### Polygon
nbo <- gadm(country = "KEN", level = 1, path = tempdir())
nbo <- nbo[nbo$NAME_1 == "Nairobi",] %>% st_as_sf()

# html
gt_make_html(location = c(40.717437418183884, -73.99145764250052),
height = 300,
width = 300,
zoom = 15,
filename = paste0("~/Desktop/test123.html"),
google_key = google_key)

# Make raster
r <- gt_make_raster_from_polygon(polygon = nbo,
zoom = 14,
Expand Down

0 comments on commit 0b26d84

Please sign in to comment.