This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An R script showing how to create a 3D night-time scene of the 'City of London' borough with {EAlidaR } and {Rayshader} | |
# If you don't already have the {EAlidaR package} Run: | |
# devtools::install_github('h-a-graham/EAlidaR') | |
library(EAlidaR) | |
library(raster) | |
library(sf) | |
library(tidyverse) | |
library(here) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.support.ui import Select | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
# from selenium.webdriver.firefox.options import Options | |
import pandas as pd | |
import math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this adds colours to the right hand facets | |
colour_right_facets <- function(plot){ | |
g <- ggplot_gtable(ggplot_build(plot)) | |
stripr <- which(grepl('strip-r', g$layout$name)) | |
fills <- c("grey90","grey70","grey50") | |
k <- 1 | |
for (i in stripr) { | |
j <- which(grepl('rect', g$grobs[[i]]$grobs[[1]]$childrenOrder)) | |
g$grobs[[i]]$grobs[[1]]$children[[j]]$gp$fill <- fills[k] | |
k <- k+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rayshader) | |
library(sf) | |
library(ggmap) | |
library(EAlidaR) | |
# ------------ User Inputs --------------------------------- | |
# Googple maps API KEY | |
register_google(key = "[PUT YOUR API KEY HERE!!]") # Create your own key as shown in the ggmap documentation: https://github.com/dkahle/ggmap | |
# WGS84 lat Long centroid location for your scene... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# So this is just a test to see the fastests way to go from a dataframe with | |
# two coordinates per row (split into 4 columns - 2 for x and 2 for y) to a | |
# linestring for each set of coordinates. | |
# minimal example. | |
library(sfheaders) | |
library(wk) | |
library(sf) | |
library(tidyverse) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(gdalio) | |
library(rnaturalearth) | |
library(dplyr) | |
library(sf) | |
library(lubridate) | |
library(magick) | |
library(terra) | |
source(system.file("raster_format/raster_format.codeR", | |
package = "gdalio", mustWork = TRUE)) # helper functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find area difference of two lines and group by whether one line is higher or | |
# lower than the other. Possiblt a long way round but it works! | |
#--------- Load packages ------------- | |
library(wk) | |
library(sf) | |
library(tidyverse) | |
#------------- Create some fake data in long form --------------- | |
fake_df <- tibble(scenario = c(rep('high',6),rep('low',6)), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Raster Mask Benchmark | |
library(sf) | |
library(terra) | |
library(dplyr) | |
library(elevatr) | |
library(microbenchmark) | |
# library(tictoc) | |
library(bench) | |
# ------ get data ------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# easy height data for rayshader | |
# remotes::install_github("hypertidy/topography") | |
library(gdalio) | |
library(topography) | |
library(sf) | |
library(rayshader) | |
library(scico) | |
library(dplyr) | |
# ------ get data ------------- | |
# Get county data for England and Wales |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!"here" %in% installed.packages()[,"Package"]) install.packages('here') | |
library(here) | |
dir_home <- here() | |
# Function to un-nest all files in sub directories. | |
unnest_dir <- function(.root, sep="_DIR_SEP_"){ | |
#list all the files in the directory and sub dirs | |
files <- list.files(.root, full.names = F, recursive = T) |
OlderNewer