# 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")
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
#' Aggregate sf objects | |
#' | |
#' Geometries and attributes are aggregated. | |
#' | |
#' @param x sf object | |
#' @param by name of the variable of grouping elements | |
#' @param var name(s) of the variable(s) to aggregate | |
#' @param fun function(s) to compute the summary statistics | |
#' | |
#' @return An sf object is returned |
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)
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(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") | |
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))
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(sf) | |
library(osrm) | |
library(maptiles) | |
# build a bbox for Paris | |
bb <- st_bbox(c(xmin = 643069, ymin = 6857478, | |
xmax = 661079, ymax = 6867081), | |
crs = 2154) | |
# get map tiles | |
osm <- get_tiles(x = bb, provider = "CartoDB.PositronNoLabels", | |
crop = TRUE, zoom = 13) |
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(sf) | |
library(elevatr) | |
library(raster) | |
library(tanaka) | |
# a polygon of bangalore | |
bangalore <- st_read("export.geojson") | |
elevation <- get_elev_raster(bangalore, z = 10) | |
bangalore_elevation <- trim(mask(elevation, bangalore)) | |
# inspect min and max values |
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(rnaturalearth) | |
library(cartography) | |
library(sf) | |
lakes <- ne_download(scale = 10, type = "lakes", category = c("physical"), | |
destdir = tempdir(), load = TRUE, returnclass = c("sf")) | |
countries <- ne_download(scale = 10, type = "countries", | |
category = c("cultural"), destdir = tempdir(), | |
load = TRUE, returnclass = c("sf")) | |
countries <- st_transform(countries, "ESRI:54017") |
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(units) | |
library(sf) | |
library(cartography) | |
# library(osmdata) | |
# | |
# # define a bounding box | |
# q0 <- opq(bbox = c(2.2247, 48.8188, 2.4611, 48.9019)) | |
# | |
# # extract Paris boundaries |
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(sf) | |
nc = st_read(system.file("shape/nc.shp", package="sf")) | |
nc <- st_transform(nc, 32119) | |
# regular grid 512096 polygons | |
grid <- st_make_grid(x = nc, cellsize = 500) | |
t0 <- Sys.time() | |
plot(st_geometry(nc)) | |
plot(grid, add = TRUE) | |
# end of the second plot |
NewerOlder