ドイツの中央部、ハノーファー近くにあるBraunschweigでの交通事故(unfall)のデータを取得して地図上にプロットしてみます。
データは、Statische Aemter des Bundes und der LaenderのUnfallatlasサイトから、2020年のデータ「Download Unfallorte 2020 – shapefile (zip)」をダウンロードして使用します。
Braunschweigのde:amtlicher_gemeindeschluesselは、03101000 です。OpenStreetMapで確認しました。
地図は、mapviewで表示します。
library(sf)
library(tidyverse)
library(osmdata)
library(mapview)
accidents <- st_read("./BS_Shapefile/Unfallorte2020_LinRef.shp") %>%
st_zm()
BS <- opq(bbox = 'braunschweig germany') %>%
add_osm_feature(key = 'de:amtlicher_gemeindeschluessel', value = '03101000') %>%
osmdata_sf ()
BS <- BS$osm_multipolygons$geometry
accidents_BS_index <- st_intersects(accidents, st_transform(BS, 25832), sparse = F)
accidents_BS <- accidents[accidents_BS_index, ] %>% st_transform(4326)
coords <- st_coordinates(accidents_BS)
accidents_BS["lng"] <- coords[,1]
accidents_BS["lat"] <- coords[,2]
mapview_accidents_points = mapview(accidents_BS, cex = 3, alpha = .5, popup = NULL)
mapview_accidents_points

当然かもしれませんが、中心部に偏っています。Braunschweigはかなり街の中心まで車が侵入できますから、そのことも影響してそうですね。
