3 Using Official Route Data
To make most effective use of the telemetry data, we want to be able to identify the stage section data as well as the road section data. We can use the official stage route to filter data points from a set of location data that includes road section locations to just those points that lay along a route.
# Path to the route telemetry data = "../../wrcplus/notebooks/2021_secto_Rally_Finland" path = "data/finland_2021.geojson"geojson_filename
For more information on analysing rally stage routes, see Visualising WRC Rally Stages With rayshader and R.
3.1 Loading Official Stage Route Data
Let’s load in some route data:
## Reading layer `finland_2021' from data source ## `/Users/tonyhirst/Documents/GitHub/visualising-wrc-telemetry-data/src/data/finland_2021.geojson' ## using driver `GeoJSON' ## Simple feature collection with 13 features and 2 fields ## Geometry type: GEOMETRY ## Dimension: XYZ ## Bounding box: xmin: 24.86575 ymin: 61.52393 xmax: 26.20794 ymax: 62.39946 ## z_range: zmin: 0 zmax: 148.839 ## Geodetic CRS: WGS 84
Let’s also clean the data a little by removing the reference to the Z dimension, making a note of original co-ordinate reference scheme, and generating references to the route in both latlong and UTM forms:
= geojson_sf[7,] %>% st_zm() stage_route # Grab a copy of the original projection = st_crs(stage_route) original_crs # Find the UTM zone for a sample a point on the route = lonlat2UTMzone(c(st_coordinates(stage_route)[1,1], crs_zone st_coordinates(stage_route)[1,2])) # Create the projection string = st_crs(crs_zone)$proj4string utm_proj4_string #"+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs" # units in meters e.g. https://epsg.io/32632 # Transform the route projection = st_transform(stage_route, stage_route_utm crs = st_crs(utm_proj4_string))
3.2 Comparing Stage Route Telemetry and the Stage Route
Let’s plot the telemetry data on a map, and then compare it to the stage route data:
leaflet() %>% addProviderTiles("OpenTopoMap", group = "OSM") %>% addPolylines(data=tmp_route, color = "red", weight = 5) %>% addPolylines(data=stage_route, color = "black", weight = 3)
If you look closely at the map, you will see that the stage route trace (in black) closely follows the road indicated on the map, but the lower resolution route telemetry data (the red line) only falls at occasional points along it; a straight line connects the sample points.