::p_load(sf, tmap, tidyverse) pacman
Reminders
Check units of measurement in projected coordinates system
1 The Packages
2 Loading the Data
2.1 Traffic Accident Data
<- read_csv("data/geospatial/thai_road_accident_2019_2022.csv") %>%
rdacc_sf filter(!is.na(longitude) & longitude != "",
!is.na(latitude) & latitude !="") %>%
st_as_sf(coords = c(
"longitude", "latitude"),
crs = 4326) %>%
st_transform(crs = 32647)
2.1 Administrative Boundary
<- st_read(dsn = "data/geospatial",
adminboundary layer = "geoBoundaries-THA-ADM0")
Reading layer `geoBoundaries-THA-ADM0' from data source
`C:\kytjy\ISSS626-GAA\In-class_Ex\In-class_Ex02\data\geospatial'
using driver `ESRI Shapefile'
Simple feature collection with 1 feature and 5 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 97.34381 ymin: 5.612851 xmax: 105.6368 ymax: 20.46483
Geodetic CRS: WGS 84
par(bg = '#E4D5C9')
plot(adminboundary)
2.3 Thai Roads
<- st_read(dsn = "data/geospatial",
roads layer = "hotosm_tha_roads_lines_shp")
Reading layer `hotosm_tha_roads_lines_shp' from data source
`C:\kytjy\ISSS626-GAA\In-class_Ex\In-class_Ex02\data\geospatial'
using driver `ESRI Shapefile'
Simple feature collection with 2792590 features and 14 fields
Geometry type: MULTILINESTRING
Dimension: XY
Bounding box: xmin: 97.34457 ymin: 5.643645 xmax: 105.6528 ymax: 20.47168
CRS: NA