Skip to content

Instantly share code, notes, and snippets.

View marcosci's full-sized avatar
💭
in progress ...

Marco Sciaini marcosci

💭
in progress ...
View GitHub Profile
# load libraries
library(units)
library(tidyverse)
library(osmdata)
library(sf)
library(ggtext)
library(exactextractr)
library(fasterize)
library(ggtext)
library(tidygeocoder)
@marcosci
marcosci / street_orientation.R
Created May 10, 2023 12:36
street_orientation
# load libraries
library(tidyverse)
library(osmdata)
library(sf)
library(ggtext)
library(exactextractr)
library(fasterize)
library(ggtext)
library(tidygeocoder)
library(glue)
library(dplyr)
library(rayshader)
library(rayrender)
library(sf)
library(fasterize)
library(raster)
library(exactextractr)
library(rayrender)
library(terra)
library(antanym)
library(sf)
library(rnaturalearth)
library(tidyverse)
library(ggtext)
sf_use_s2(FALSE)
tmp_dr <- tempdir()
tmp_fl <- tempfile()
@marcosci
marcosci / hiroshima.R
Created November 2, 2022 14:01
What if it was your city?
# load libraries
library(tidyverse)
library(osmdata)
library(sf)
library(ggtext)
library(exactextractr)
library(fasterize)
library(ggtext)
library(tidygeocoder)
library(glue)
@marcosci
marcosci / day02_lines.R
Created November 2, 2022 12:29
Graticules for ggplot2 and sf
library(sf)
library(tidyverse)
projections <- c("+proj=laea",
"+proj=moll",
"+proj=adams_ws2",
"+proj=urm5 +n=0.9",
"+proj=wintri",
"+proj=bonne +lat_1=10",
"+proj=eck1",
library(rayshader)
library(rayrender)
library(terra)
library(rnaturalearth)
library(MetBrewer)
library(raster)
library(exactextractr)
library(fasterize)
canopy_germany <- rast("germany/canopy_germany.tif")
library(tidyverse)
library(patchwork)
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.3, PROJ 7.2.1; sf_use_s2() is TRUE
poly <- st_polygon(list(cbind(c(0,1,1,0,0), c(0,0,1,1,0))))
poly_grid <- st_sf(st_make_grid(poly, cellsize = 0.01))
poly_grid[1:490, "group"] <- 1
poly_grid[491:3600, "group"] <- 2
options(
repos = c(tylermorganwall = 'https://tylermorganwall.r-universe.dev',
CRAN = 'https://cloud.r-project.org')
)
install.packages('rayrender')
library(rayrender)
for (i in seq(720, 1, by = -1)) {
generate_studio(depth = -1, material = diffuse(color = "white")) %>%
add_object(sphere(
@marcosci
marcosci / render_universe.R
Created December 8, 2021 07:54
Rayrender Universe
library(rayrender)
library(glue)
y_dist = 8
circle <- function(x = 0, y = 0 + 20, rad = 1, nvert = 500, ...){
rads <- seq(0,2*pi,length.out = nvert)
xcoords <- cos(rads) * rad + x
ycoords <- sin(rads) * rad + y
cbind(x = xcoords, y = y_dist, z = ycoords)