Created
April 21, 2022 08:45
-
-
Save jvieroe/32d3b6ed336c4a6827e00cd75e8699d4 to your computer and use it in GitHub Desktop.
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(tidyverse) | |
library(sf) | |
library(tmap) | |
tmap_mode("view") | |
url <- "https://api.dataforsyningen.dk/afstemningsomraader?format=geojson" | |
ao <- read_sf(url) | |
temp <- ao %>% | |
st_drop_geometry() | |
# fra adresser til koordinater: brug DAWAs datavask | |
# https://dawadocs.dataforsyningen.dk/dok/guide/datavask | |
# (snak evt. med Anders Toft) | |
individuals <- tribble(~navn, ~lat, ~lon, | |
"kristian", 55.758009580556575, 12.572310769589679, | |
"jeppe", 55.70108585150052, 12.540437740752816) %>% | |
st_as_sf(coords = c("lon", "lat"), | |
crs = 4326) | |
tm_shape(ao) + | |
tm_polygons(col = "red", alpha = .3) + | |
tm_shape(individuals) + | |
tm_dots() | |
# match dem! | |
matches <- st_join(individuals, | |
ao, | |
join = st_nearest_feature) | |
matches |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment