The aptly named roads() function will pull road linestrings.
Riv_roads<-roads(state ='CA', county ='Riverside', year =2023, progress_bar =FALSE)|>st_transform(crs =4326)head(Riv_roads)
Simple feature collection with 6 features and 4 fields
Geometry type: LINESTRING
Dimension: XY
Bounding box: xmin: -117.5613 ymin: 33.49898 xmax: -116.3334 ymax: 33.87767
Geodetic CRS: WGS 84
LINEARID FULLNAME RTTYP MTFCC
1 110458254891 Armstrong Dr Exd M S1400
2 110458266265 Gabino Canyon Rd N Spr M S1400
3 1102175699783 Porphyry Spr M S1400
4 110458248901 Pub Utility Acc M S1400
5 1103677442858 White Horse Pvt M S1740
6 1103678156677 Bus Park Dr M S1400
geometry
1 LINESTRING (-117.5613 33.83...
2 LINESTRING (-117.51 33.5231...
3 LINESTRING (-117.5396 33.87...
4 LINESTRING (-117.1296 33.50...
5 LINESTRING (-116.3343 33.75...
6 LINESTRING (-117.1577 33.49...
There are 58,448 road segments from 2023. That’s a lot of lines for a map and takes too long to load. Feel free to make a map with it if you want to hear your computer hum.
For the purpose of the road widening project, we’re mostly focusing on big roads getting widened. The documentation for roads() states that the RTTYP category provides six types.
I’m going to filter just the Interstate (I) and State (S) roads for this version.
There are only 81 major roads segments that meet that criteria.
leaflet()|>addTiles()|>addPolylines(data =Riv_major_roads, color ='black', weight =3, dashArray ='2,6', #new feature - makes lines dashed - line lenght, space length label =~FULLNAME)
Now let’s add Riverside County warehouses for a quick look at the proximity of those facilities to current major roadways. We did this in lesson 10.3.2