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(osmdata) | |
library(sf) | |
# Punto a caso in Israele | |
coords <- c(34.8, 32) | |
coords <- st_sfc(st_point(x = coords), crs = 4326) | |
# Trasformazione nella proiezione Israeli TM Grid | |
# https://spatialreference.org/ref/epsg/israel-israeli-tm-grid/ | |
coords_proj <- st_transform(coords, 2039) | |
# Ho proiettato così da creare un vero cerchio con un raggio in metri |
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
# Download earth data first | |
# https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_land.zip | |
library(sf) | |
library(lwgeom) | |
library(dplyr) | |
library(ggplot2) | |
library(mapview) | |
# Read the 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
library(sf) | |
get_utm_crs <- function(dat) { | |
# To determine UTM CRS, first compute average longitude points | |
if(st_crs(dat)$epsg != 4326) { | |
dat <- st_transform(dat, crs = 4326) | |
} | |
# Extra step if dat is not only made of points |
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(plyr) | |
library(osmdata) | |
library(sf) | |
library(dplyr) | |
# Per prima cosa scarico separatamente i confini delle regioni (admin_level = 4), un pezzo alla volta | |
# Questo mi consente di avere una bounding box più precisa per scaricare successivamente le province | |
# Se il server da un timeout, bisogna definire più di 4 queries | |
# Nord Italia (circa) |