Skip to content

Instantly share code, notes, and snippets.

View rCarto's full-sized avatar
🛠️
...

Timothée Giraud rCarto

🛠️
...
View GitHub Profile
library(mapsf)
#> Le chargement a nécessité le package : sf
#> Linking to GEOS 3.7.1, GDAL 3.1.2, PROJ 7.1.0
mtq <- mf_get_mtq()
mf_theme("nevermind")
mf_map(mtq, graticule = st_crs(4326), 
       axes = TRUE, 
       lon = seq(-60,-62, by=-.2), 
 lat = seq(14, 15, by = .2))
library(rnaturalearth)
library(mapsf)
library(fisheye)
ct <- ne_download(scale = 50, returnclass = "sf")
oc <- ne_download(type = "ocean", category = "physical",
scale = 50, returnclass = "sf")
x <- st_transform(ct, "+proj=natearth2")
z <- st_transform(oc, "+proj=natearth2")
orthomap <- function(lon, lat) {
  g <- as_s2_geography(TRUE)
  co <- s2_data_countries()
  oc <- s2_difference(g, s2_union_agg(co)) # oceans
  co <- s2_difference(co, s2_union_agg(oc)) # land
  
  # visible half
  b <- s2_buffer_cells(as_s2_geography(paste0("POINT(", lon, " ", lat,")")),
                       distance = 9800000)
@rCarto
rCarto / maptiles.md
Last active December 12, 2023 09:42
# Your Stadia API key:
apikey = "xxxxxxxxxxxxxxxxxxxxxxx"

# Define a bounding box
library(sf)
bb <- st_bbox(obj = c(xmin = 24.73592, xmax = 24.75185, 
                      ymin = 59.4340, ymax = 59.4393), 
              crs = "EPSG:4326")