Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
library(magrittr)
library(sf)
library(lwgeom)
library(sfnetworks)
library(osmdata)
library(ggspatial)
library(mapview)
library(tidygraph)
q1 <- opq(c(35.18,31.75,35.22,31.77)) %>%
library(tidyverse)
library(magrittr)
library(sf)
library(lwgeom)
library(sfnetworks)
library(osmdata)
library(ggspatial)
library(mapview)
library(tidygraph)
library(SpatialPosition)
library(osmdata)
library(tidyverse)
library(tidygraph)
library(igraph)
library(sf)
library(lwgeom)
library(sfnetworks)
library(stplanr)
df <- getbb("Jerusalem",format_out = "polygon")
@idshklein
idshklein / gginset.R
Created November 5, 2020 07:21
making map inset with ggplot
library(sf)
library(tidyverse)
library(patchwork)
nc = st_read(system.file("shape/nc.shp", package="sf"))
box <- nc %>% st_bbox()
minify_box <- function(bbox, ratio = 0.5){
if(class(bbox) != "bbox"){
stop("bbox must be a bbox object")
}
if(class(ratio) != "numeric" ){
library(tidyverse)
library(sf)
library(esri2sf)
library(tidygraph)
library(sfnetworks)
library(ggspatial)
Sys.setlocale(locale = "hebrew")
# https://gisviewer.jerusalem.muni.il/arcgis/rest/services/BaseLayers/MapServer
jlm_net <- esri2sf("https://gisviewer.jerusalem.muni.il/arcgis/rest/services/BaseLayers/MapServer/27") %>%
st_transform(2039)
library(tidyverse)
library(sf)
# library(nngeo)
df <- st_read("D:/idos_shit/tlv_struc.gpkg") %>%
st_transform(2039)
has_year <- df %>% filter(!is.na(year),year != 0)
hasnt_year <- df %>% filter(is.na(year) | year == 0)
# st_nn(hasnt_year,has_year)
library(tidyverse)
library(sf)
library(esri2sf)
jlm <- esri2sf("https://gisviewer.jerusalem.muni.il/arcgis/rest/services/BaseLayers/MapServer/41")
coords <- st_union(jlm) %>%
st_transform(2039) %>%
st_sample(10000) %>%
st_coordinates()
clus <- coords %>%
kmeans(100)
library(tidyverse)
library(sf)
library(spdep)
library(rnaturalearth)
names <- ne_countries() %>%
st_as_sf() %>%
st_drop_geometry() %>%
pull(name)
mat <- ne_countries() %>%
st_as_sf() %>%
library(tidyverse)
library(gganimate)
library(sf)
CLUSTERS <- 100
map(0:50,function(max.iter){
set.seed(12)
df <- data.frame(x = runif(100000,0,1000),
y = runif(100000,0,1000))
centers <- data.frame(x = 500 + runif(CLUSTERS,-100,100),
y = 500 + runif(CLUSTERS,-100,100))
library(tidyverse)
library(sf)
library(sfnetworks)
library(cluster)
library(crsuggest)
library(tidygraph)
library(ggspatial)
# library(gganimate)
crsuggest::suggest_crs(roxel)
net <- roxel %>%