d_world <- ne_countries() |>
select(admin, adm0_a3, geometry) |>
filter(adm0_a3 != "ATA")2026-03-19
GIS Layer, Quelle: http//landportal.org
ISO3 (Ländercode)geometry (Geometrie eines Landes als Simple Feature)ne_countries() als sf-Objekt (weitere Infos hier)select() auswählen
sf Dataframes mit geom_sf()EPSG:8857st_area()sf-Paket beginnen mit st_ (🤯)as.numeric(), umrechnen in Quadratkilometer→ Choroplethenkarte, Flächenkartogramm oder Flächenwertstufenkarte
wb_data() (Paket wbstats) herunterladen
adm0_a3 habengeom_pointgeom_point() wie gehabtgeom_sfst_as_sf
coords angeben in welchen Spalten die Koordinaten stehengeom_sfgiscoRgiscoR (R-Schnittstelle zu Daten der EU)gisco_get_nuts
country Landnuts_level gibt Ebene an Staat/Bundesländer/Regierungsbezirkeresolution Auflösung, siehe Dokumentationosmdata (https://github.com/ropensci/osmdata)getbb (bb steht für Bounding Box)q erzeugen mit opqadd_osm_feature
key ist die Kategorievalue sagt was genau gemeint istosmdata_sf zur Verwendung mit SF aufbereiten
osm_points, osm_lines, osm_polygons, …$osm_lines die Linien heraussuchenif (!file.exists("daten/strassen-bochum.RData")) {
q <- opq(getbb("Bochum, Germany"))
s1 <- add_osm_feature(q, key = "highway", value = c("motorway", "primary", "motorway_link", "primary_link")) |> osmdata_sf()
s2 <- add_osm_feature(q, key = "highway", value = c("secondary", "tertiary", "secondary_link", "tertiary_link")) |> osmdata_sf()
s3 <- add_osm_feature(q, key = "highway", value = c("unclassified", "residential")) |> osmdata_sf()
f1 <- add_osm_feature(q, key = "waterway", value = "river") |> osmdata_sf()
u1 <- add_osm_feature(q, key = "amenity", value = "university") |> osmdata_sf()
save(s1, s2, s3, f1, u1, file = "daten/strassen-bochum.RData")
} else {
load(file = "daten/strassen-bochum.RData")
}c mehrere Objekte aus einer Kategorie kombinierenp <- ggplot() +
geom_sf(data = u1$osm_polygons, color = "orange", linewidth = 0.35) +
geom_sf(data = f1$osm_lines, color = "steelblue", linewidth = 0.35) +
geom_sf(data = s3$osm_lines, color = "light gray", linewidth = 0.15) +
geom_sf(data = s2$osm_lines, color = "dark gray", linewidth = 0.25) +
geom_sf(data = s1$osm_lines, color = "black", linewidth = 0.35) +
coord_sf(xlim = c(7.1, 7.3), ylim = c(51.41, 51.52)) +
theme_void()p speichern und auf nächster Folie ausgebenif (!file.exists("daten/bab.RData")) {
bab_raw <- opq(bbox = getbb("Deutschland", featuretype = "country")) |>
add_osm_feature(key = "highway", value = "motorway") |>
osmdata_sf()
d_bab <- bab_raw$osm_lines |>
st_filter(d_de, .predicate = st_within) |>
drop_na(ref) |>
group_by(ref) |>
summarise() |>
st_simplify(dTolerance = 100)
save(d_bab, file = "daten/bab.RData")
} else {
load(file = "daten/bab.RData")
}coord_sf festlegenopq angeben (und nicht mittels getbb)st_read()Bausteine Computergestützter Datenanalyse