Last active
February 23, 2021 04:25
-
-
Save mikemahoney218/c3294e3d70c393bc1a955c39ec9fbf58 to your computer and use it in GitHub Desktop.
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(terrainr) # remotes::install.github("ropensci/terrainr") | |
library(sf) | |
library(ggplot2) | |
library(progressr) | |
handlers("progress") | |
simulated_data <- data.frame(id = seq(1, 100, 1), | |
lat = runif(100, 44.04905, 44.17609), | |
lng = runif(100, -74.01188, -73.83493)) | |
simulated_data <- st_as_sf(simulated_data, coords = c("lng", "lat")) | |
simulated_data <- st_set_crs(simulated_data, 4326) | |
with_progress( | |
output_tiles <- get_tiles(simulated_data, | |
services = c("elevation", "ortho"), | |
resolution = 90 | |
) | |
) | |
ele_df <- raster::as.data.frame(raster::raster(output_tiles[["elevation"]]), xy = TRUE) | |
names(ele_df) <- c("x", "y", "val") | |
ggplot() + | |
geom_spatial_rgb(data = output_tiles[["ortho"]], | |
aes(x = x, y = y, r = red, g = green, b = blue), alpha = 0.1) + | |
ggnewscale::new_scale_fill() + | |
geom_raster(data = ele_df, aes(x = x, y = y, fill = val)) + | |
geom_sf(data = simulated_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment