-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTransport_RhodeIslandPDF.Rmd
3883 lines (3488 loc) · 219 KB
/
Transport_RhodeIslandPDF.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: "Transportation Options in Rhode Island"
author: "Marcos Luna and Neenah Estrella-Luna"
date: "`r Sys.Date()`"
output:
bookdown::pdf_document2:
toc: true
toc_depth: 3
number_sections: true
fig_caption: yes
includes:
in_header: my_header.tex
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo=FALSE, message=FALSE, warning=FALSE)
library(tidyverse)
library(sf)
library(tmap)
library(tidytransit)
library(sp)
library(tigris)
options(tigris_use_cache = TRUE, tigris_class = "sf")
library(lubridate)
library(maptools)
library(spdep)
library(lwgeom)
```
\pagebreak
# Analysis of adequacy of public transit, walkability, and transportation cost burden in Rhode Island
This is an analysis of access to public transit and walkability in Rhode Island.
```{r data, include=FALSE}
### Analysis of Rhode Island transportation options
load("DATA/ne_layers.rds")
rm(ne_blkgrp_sf90)
### Read in RI transit data. See http://www.rigis.org/
# read in RIPTA bus routes
ri_busroutes_sf <- st_read(dsn = "DATA/transport/RI/RIPTA_Bus_Routes",
layer = "RIPTA_Bus_Routes")
# read in RIPTA bus stops
ri_busstops_sf <- st_read(dsn = "DATA/transport/RI/RIPTA_Bus_Stops",
layer = "RIPTA_Bus_Stops")
# read in RI ferry routes
ri_ferryroutes_sf <- st_read(dsn = "DATA/transport/RI/RI_Ferry_Routes",
layer = "Ferry_Routes")
# read in RI railroad rights of way
ri_railrow_sf <- st_read(dsn = "DATA/transport/RI/RI_Railroad_Rights_of_Way",
layer = "Railroad_Rights_of_Way") %>%
filter(STATUS == "Active" & RAILUSE == "Passenger")
# read in RI park and ride stops
ri_parknride_sf <- st_read(dsn = "DATA/transport/RI/RIPTA_Park_and_Ride_Stops",
layer = "RIPTA_Park_and_Ride_Stops")
# Convert to projected local CRS EPSG:2840: NAD83(HARN) / Rhode Island
ri_busstops_sf <- st_transform(ri_busstops_sf, crs = 2840)
ri_blkgrps_sf <- ne_blkgrp_sf %>%
filter(STATE == "Rhode Island") %>%
st_transform(., crs = 2840) %>%
mutate(PopAcre = totalpopE/(bg_area_m2*0.000247105))
ri_tracts_sf <- ne_tracts_sf %>%
filter(STATE == "Rhode Island") %>%
st_transform(., crs = 2840)
# Get rid of empty geometries
empty_geo <- st_is_empty(ri_blkgrps_sf)
ri_blkgrps_sf <- ri_blkgrps_sf[!empty_geo,]
empty_geo <- st_is_empty(ri_tracts_sf)
ri_tracts_sf <- ri_tracts_sf[!empty_geo,]
# Use dasymetric mapping to calculate populations with access to transit. Approach follows method used by Qiang (2019) to eliminate unpopulated areas of census polygons and then reallocate populations to developed areas as identified in National Land Cover Dataset (NLCD).
# Perform NLCD raster-to-vector conversion, vector erase/difference, and vector intersections in ArcMap because it takes too long in R.
# In ArcMap:
# Convert NLCD raster to shapefile. Clip to state.
# Isolate undeveloped areas (gridcode NOT 22 - 24).
# Erase areas of block groups and tracts that overlap with undeveloped areas in NLCD shapefiles. Compute OldArea of erased polygons in sqm to identify area of developed polygons remaining.
##### Return to working in R ######
# # read in processed ma_blkgrps and ma_tracts
# st_layers(dsn = "DATA/FEMA/MA")
ri_blkgrps_developed <- st_read(dsn = "DATA/FEMA/RI",
layer = "ri_blkgrps_developed")
ri_blkgrps_developed <- ri_blkgrps_sf %>%
mutate(RI_LOWINC = if_else(RI_INCOME == "I",totalpopE,0)) %>%
mutate(RI_LOWINC = replace_na(RI_LOWINC,0)) %>%
mutate(RI_MINORITIES = if_else(RI_MINORITY == "M",totalpopE,0)) %>%
mutate(RI_MINORITIES = replace_na(RI_MINORITIES,0)) %>%
as.data.frame() %>%
dplyr::select(-geometry) %>%
left_join(ri_blkgrps_developed, ., by = "GEOID") %>%
st_transform(., crs = 2840) %>%
mutate(NewArea = st_area(.)) %>%
st_make_valid() %>%
mutate(Proportion = as.numeric(NewArea/OldArea),
NewPop = totalpopE*Proportion,
NewMinority = minorityE*Proportion,
NewUnder5 = under5E*Proportion,
NewOver64 = over64E*Proportion,
NewUnder18 = under18E*Proportion,
NewEng_limit = eng_limitE*Proportion,
NewPov = num2povE*Proportion,
NewLths = lthsE*Proportion,
NewRI_LOWINC = RI_LOWINC*Proportion,
NewRI_MINORITIES = RI_MINORITIES*Proportion,
NewPopAcre = NewPop/(NewArea*0.000247105))
ri_tracts_developed <- st_read(dsn = "DATA/FEMA/RI",
layer = "ri_tract_developed") %>%
left_join(., as.data.frame(ri_tracts_sf), by = "GEOID") %>%
st_transform(., crs = 2840) %>%
mutate(NewArea = st_area(.)) %>%
st_make_valid() %>%
mutate(Proportion = as.numeric(NewArea/OldArea),
NewDisabled = disabledOver18E*Proportion,
NewOver18 = Over18E*Proportion,
NewHHNoCar = HHnoCarE*Proportion)
# create a simplified version for faster mapping
ri_blkgrps_developed_simple <- st_simplify(ri_blkgrps_developed,
dTolerance = 100) %>%
filter(!st_is_empty(.)) %>%
st_make_valid()
# repeat for tracts
ri_tracts_developed_simple <- st_simplify(ri_tracts_developed,
dTolerance = 100) %>%
filter(!st_is_empty(.)) %>%
st_make_valid()
# # clean up
# rm(list = ls(pattern = "ne_"))
# Create a 400m buffer around bus stops
ri_busBuff400m <- st_buffer(ri_busstops_sf,dist = 400) %>%
st_union() %>%
st_as_sf()
# Use areal interpolation to calculate priority populations within buffer of accessibility
ri_busBuff400m_sf <- ri_blkgrps_developed %>%
select(GEOID,NewArea:NewRI_MINORITIES) %>%
mutate(OldArea = NewArea) %>%
st_intersection(ri_busBuff400m,.) %>%
mutate(NewArea = st_area(.),
Proportion = NewArea/OldArea,
NewPop = as.integer(NewPop*Proportion),
NewMinority = as.integer(NewMinority*Proportion),
NewUnder5 = as.integer(NewUnder5*Proportion),
NewOver64 = as.integer(NewOver64*Proportion),
NewUnder18 = as.integer(NewUnder18*Proportion),
NewEng_limit = as.integer(NewEng_limit*Proportion),
NewPov = as.integer(NewPov*Proportion),
NewLths = as.integer(NewLths*Proportion),
NewRI_LOWINC = as.integer(NewRI_LOWINC*Proportion),
NewRI_MINORITIES = as.integer(NewRI_MINORITIES*Proportion))
# Repeat for tracts
ri_busBuff400mTracts_sf <- ri_tracts_developed %>%
select(GEOID,NewDisabled:NewHHNoCar) %>%
mutate(OldArea = st_area(.)) %>%
st_intersection(ri_busBuff400m,.) %>%
mutate(NewArea = st_area(.),
Proportion = NewArea/OldArea,
NewDisabled = as.integer(NewDisabled*Proportion),
NewNoCar = as.integer(NewHHNoCar*Proportion))
# # Use areal interpolation to calculate priority populations within buffer of accessibility
# ri_busBuff400m_sf <- ri_blkgrps_sf %>%
# mutate(RI_LOWINC = if_else(RI_INCOME == "I",totalpopE,0)) %>%
# mutate(RI_LOWINC = replace_na(RI_LOWINC,0)) %>%
# mutate(RI_MINORITIES = if_else(RI_MINORITY == "M",totalpopE,0)) %>%
# mutate(RI_MINORITIES = replace_na(RI_MINORITIES,0)) %>%
# select(GEOID,
# totalpopE,
# minorityE,
# under5E,
# over64E,
# under18E,
# eng_limitE,
# num2povE,
# lthsE,
# RI_LOWINC,
# RI_MINORITIES) %>%
# mutate(OldArea = st_area(.)) %>%
# st_intersection(ri_busBuff400m,.) %>%
# mutate(NewArea = st_area(.),
# Proportion = NewArea/OldArea,
# NewPop = as.integer(totalpopE*Proportion),
# NewMinority = as.integer(minorityE*Proportion),
# NewUnder5 = as.integer(under5E*Proportion),
# NewOver64 = as.integer(over64E*Proportion),
# NewUnder18 = as.integer(under18E*Proportion),
# NewEng_limit = as.integer(eng_limitE*Proportion),
# NewPov = as.integer(num2povE*Proportion),
# NewLths = as.integer(lthsE*Proportion),
# NewRI_LOWINC = as.integer(RI_LOWINC*Proportion),
# NewRI_MINORITIES = as.integer(RI_MINORITIES*Proportion))
#
# # Repeat for tracts
# ri_busBuff400mTracts_sf <- ri_tracts_sf %>%
# select(GEOID,
# disabledOver18E,
# HHnoCarE) %>%
# mutate(OldArea = st_area(.)) %>%
# st_intersection(ri_busBuff400m,.) %>%
# mutate(NewArea = st_area(.),
# Proportion = NewArea/OldArea,
# NewDisabled = as.integer(disabledOver18E*Proportion),
# NewNoCar = as.integer(HHnoCarE*Proportion))
# Compute total block group populations within bus stop buffer
ri_busBuff400m_df <- ri_busBuff400m_sf %>%
as.data.frame() %>%
summarize(`Total Pop` = sum(NewPop),
Minority = sum(NewMinority),
`Under 5` = sum(NewUnder5),
`Over 64` = sum(NewOver64),
`Under 18` = sum(NewUnder18),
`Limited English HH` = sum(NewEng_limit),
`Low Income` = sum(NewPov),
`No HS Dip` = sum(NewLths),
`RI Low Income` = sum(NewRI_LOWINC),
`RI Minority` = sum(NewRI_MINORITIES)) %>%
gather(key = Group, value = BusPop)
# Compute total tract populations within bus stop buffer
ri_busBuff400mTracts_df <- ri_busBuff400mTracts_sf %>%
as.data.frame() %>%
summarize(`Disabled` = sum(NewDisabled),
`No Car HH` = sum(NewNoCar)) %>%
gather(key = Group, value = BusPop)
# Compute total tract populations within the state for same groups
ri_tract_pops_df <- ri_tracts_sf %>%
as.data.frame() %>%
summarize(`Disabled` = sum(disabledOver18E),
`No Car HH` = sum(HHnoCarE)) %>%
gather(key = Group, value = RIPop) %>%
left_join(.,ri_busBuff400mTracts_df, by = "Group")
# Compute populations for state, join with buffer pops
ri_busAccessPops_df <- ri_blkgrps_sf %>%
as.data.frame() %>%
mutate(RI_LOWINC = if_else(RI_INCOME == "I",totalpopE,0)) %>%
mutate(RI_LOWINC = replace_na(RI_LOWINC,0)) %>%
mutate(RI_MINORITIES = if_else(RI_MINORITY == "M",totalpopE,0)) %>%
mutate(RI_MINORITIES = replace_na(RI_MINORITIES,0)) %>%
summarize(`Total Pop` = sum(totalpopE),
Minority = sum(minorityE),
`Under 5` = sum(under5E),
`Over 64` = sum(over64E),
`Under 18` = sum(under18E),
`Limited English HH` = sum(eng_limitE),
`Low Income` = sum(num2povE),
`No HS Dip` = sum(lthsE),
`RI Low Income` = sum(RI_LOWINC, na.rm = TRUE),
`RI Minority` = sum(RI_MINORITIES, na.rm = TRUE)) %>%
gather(key = Group, value = RIPop) %>%
left_join(., ri_busBuff400m_df, by = "Group") %>%
rbind(.,ri_tract_pops_df) %>%
mutate(PctBus = BusPop/RIPop*100)
# create point layer of towns for context
ri_towns_sf_pts <- county_subdivisions(state = "RI", cb = TRUE) %>%
filter(NAME %in% c("Providence",
"Woonsocket",
"Pawtucket",
"Warwick",
"Bristol",
"Portsmouth",
"Newport",
"Narragansett",
"North Kingstown",
"Charlestown",
"Situate",
"Glocester",
"Burrillville",
"Scituate",
"Coventry",
"Hopkinton",
"South Kingstown",
"Tiverton",
"New Shoreham",
"Westerly")) %>%
st_transform(., crs = 2840) %>%
st_centroid(of_largest_polygon = TRUE)
# Create road layer for context
ri_highways <- tigris::primary_roads() %>%
filter(FULLNAME %in% c("I- 95","I- 195","I- 295", "US Hwy 6")) %>%
tmaptools::crop_shape(., ne_states_sf_cb) %>%
st_transform(., crs = 2840)
# Extract highway segments for labeling
I95roadSegment <- ri_highways %>%
filter(LINEARID == "110468245978")
I95roadSegment2 <- ri_highways %>%
filter(LINEARID == "1107052605232")
I295roadSegment <- ri_highways %>%
filter(LINEARID == "1104755623349")
I195roadSegment <- ri_highways %>%
filter(LINEARID == "110448466166")
# Create custom icons of highway shields
I95 <- tmap_icons(file = "https://upload.wikimedia.org/wikipedia/commons/thumb/6/61/I-95.svg/200px-I-95.svg.png")
I195 <- tmap_icons("https://upload.wikimedia.org/wikipedia/commons/thumb/f/f7/I-195.svg/200px-I-195.svg.png")
I295 <- tmap_icons("https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/I-295.svg/200px-I-295.svg.png")
# recode routes to match RIPTA categories
ri_busroutes_sf <- ri_busroutes_sf %>%
mutate(type = case_when(
ROUTE %in% c(3,4,6,13,17,18,19,21,22,29,30,32,33,34,35,40,49,51,55,57,58,63,64,67,72,73,75,76,78,80,87) ~ "Urban Service",
ROUTE == 11 ~ "Rapid Line",
ROUTE %in% c(8,9,10,12,14,54,59,60,61,62,65,66,95) ~ "Express Service",
ROUTE %in% c(1,20,27,28,31,50,56,71,92) ~ "Key Corridor",
ROUTE %in% c(16,203,204,210,231,242,281,282,301) ~ "Flex Service"))
# Calculate totals of priority populations for use in computing percentages in later tables
# Calculate tract populations by state
statepopsdf_tracts <- ri_tracts_sf %>%
as.data.frame() %>%
group_by(STATE) %>%
summarize(TotalDisabled = sum(disabledOver18E, na.rm = TRUE),
TotalOver18 = sum(Over18E, na.rm = TRUE),
TotalNoCar = sum(HHnoCarE, na.rm = TRUE))
statepopsdf <- ri_blkgrps_sf %>%
as.data.frame() %>%
mutate(RI_LOWINC = if_else(RI_INCOME == "I", totalpopE, 0)) %>%
mutate(RI_LOWINC = replace_na(RI_LOWINC,0)) %>%
mutate(RI_MINORITY = if_else(RI_MINORITY == "M", totalpopE,0)) %>%
mutate(RI_MINORITY = replace_na(RI_MINORITY,0)) %>%
group_by(STATE) %>%
summarize(TotalPop = sum(totalpopE, na.rm = TRUE),
TotalHH = sum(householdsE, na.rm = TRUE),
TotalLEH = sum(eng_limitE, na.rm = TRUE),
TotalMin = sum(minorityE, na.rm = TRUE),
TotalLowInc = sum(num2povE, na.rm = TRUE),
TotalNoHS = sum(lthsE, na.rm = TRUE),
TotalOver64 = sum(over64E, na.rm = TRUE),
TotalUnder5 = sum(under5E, na.rm = TRUE),
TotalUnder18 = sum(under18E, na.rm = TRUE),
TotalRI_LOWINC = sum(RI_LOWINC, na.rm = TRUE),
TotalRI_MINORITY = sum(RI_MINORITY, na.rm = TRUE)) %>%
left_join(., statepopsdf_tracts,by="STATE")
# ri_towns_sf <- ne_towns_sf %>%
# dplyr::select(GEOID,NAME) %>%
# st_transform(., crs = 2840)
ri_towns_sf <- county_subdivisions(state = "RI", cb = TRUE) %>%
st_transform(., crs = 2840)
townpopsdf_tracts <- ri_tracts_sf %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
group_by(NAME) %>%
summarize(TotalDisabled = sum(disabledOver18E, na.rm = TRUE),
TotalOver18 = sum(Over18E, na.rm = TRUE),
TotalNoCar = sum(HHnoCarE, na.rm = TRUE))
townpopsdf <- ri_blkgrps_sf %>%
dplyr::select(-GEOID) %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
mutate(RI_LOWINC = if_else(RI_INCOME == "I", totalpopE, 0)) %>%
mutate(RI_LOWINC = replace_na(RI_LOWINC,0)) %>%
mutate(RI_MINORITY = if_else(RI_MINORITY == "M", totalpopE,0)) %>%
mutate(RI_MINORITY = replace_na(RI_MINORITY,0)) %>%
group_by(NAME) %>%
summarize(GEOID = unique(GEOID),
TotalPop = sum(totalpopE, na.rm = TRUE),
TotalHH = sum(householdsE, na.rm = TRUE),
TotalLEH = sum(eng_limitE, na.rm = TRUE),
TotalMin = sum(minorityE, na.rm = TRUE),
TotalLowInc = sum(num2povE, na.rm = TRUE),
TotalNoHS = sum(lthsE, na.rm = TRUE),
TotalOver64 = sum(over64E, na.rm = TRUE),
TotalUnder5 = sum(under5E, na.rm = TRUE),
TotalUnder18 = sum(under18E, na.rm = TRUE),
TotalRI_LOWINC = sum(RI_LOWINC, na.rm = TRUE),
TotalRI_MINORITY = sum(RI_MINORITY, na.rm = TRUE)) %>%
left_join(.,townpopsdf_tracts,by="NAME")
ri_state_sf_cb <- ne_states_sf_cb %>%
filter(NAME == "Rhode Island") %>%
st_transform(., crs = st_crs(ri_blkgrps_sf))
# Identify block groups >= 1 mile from transit stops
# Create a 1 mile buffer around bus stops
ri_busBuff1mile <- st_buffer(ri_busstops_sf,dist = 1609.34) %>%
st_union() %>%
st_as_sf()
# Identify block groups that do not intersect with buffer
# ri_blkgrps_sf_noBus <- ri_blkgrps_sf %>%
# filter(st_disjoint(.,ri_busBuff1mile,sparse = FALSE))
ri_blkgrps_sf_noBus <- ri_blkgrps_developed %>%
filter(st_disjoint(.,ri_busBuff1mile,sparse = FALSE))
# Identify tracts that do not intersect with buffer
# ri_tracts_sf_noBus <- ri_tracts_sf %>%
# filter(st_disjoint(.,ri_busBuff1mile,sparse = FALSE))
ri_tracts_sf_noBus <- ri_tracts_developed %>%
filter(st_disjoint(.,ri_busBuff1mile,sparse = FALSE))
# write out to file for later analysis
save(ri_blkgrps_sf_noBus, ri_tracts_sf_noBus,
ri_busAccessPops_df, ri_blkgrps_sf_noBus, ri_busBuff400m_sf,
file = "DATA/transport/RI/noTransit.Rds")
```
## Access to Public Transit
This analysis seeks to identify communities that are underserved by access to public transit. Access to transit is measured in terms of distance to transit boarding stops and in terms of frequency of service.
Rhode Island is served primarily by the Rhode Island Public Transit Authority (RIPTA) which is a quasi-public, independent authority. This public transit service system is made up almost entirely by fixed-route bus service, which passes through 36 of Rhode Island's 39 municipalities. Amtrak train service passes through Rhode Island as well, but it is not considered in this analysis because it is not managed by the state of Rhode Island. This analysis looks at bus service access and frequency in Rhode Island. Figure \@ref(fig:transitMap) shows `r nrow(ri_busroutes_sf)` fixed public transit routes across the state along with population density.
```{r transitMap, fig.align = "center", fig.cap="Transit service and population density in Rhode Island."}
# bbox_new <- st_bbox(ri_blkgrps_sf) # current bounding box
#
# xrange <- bbox_new$xmax - bbox_new$xmin # range of x values
# yrange <- bbox_new$ymax - bbox_new$ymin # range of y values
#
# # bbox_new[1] <- bbox_new[1] - (2.2 * xrange) # xmin - left
# # bbox_new[3] <- bbox_new[3] + (2 * xrange) # xmax - right
# bbox_new[2] <- bbox_new[2] - (0.2 * yrange) # ymin - bottom
# # bbox_new[4] <- bbox_new[4] + (2 * yrange) # ymax - top
#
# bbox_new <- bbox_new %>% # take the bounding box ...
# st_as_sfc() # ... and make it a sf polygon
# # create simplified version to speed up mapping
# ri_blkgrps_developed_simple <- st_simplify(ri_blkgrps_developed, dTolerance = 100)
m <- tm_shape(ri_towns_sf, unit = "mi") +
tm_borders(col = "gray", lwd = 0.2) +
tm_shape(ri_blkgrps_developed_simple) +
tm_fill(col = "NewPopAcre", alpha = 0.8, style = "quantile",
colorNA = "white", colorNULL = "gray", title = "Pop per Acre",
legend.format = list(fun = function(x) formatC(x, digits = 1, format = "f")), palette = "YlGn") +
tm_shape(ne_states_sf_cb) + tm_borders(lwd = 0.2, alpha = 0.8) +
tm_text("STUSPS", size = 0.7, remove.overlap = TRUE, col = "gray") +
tm_shape(ri_highways) + tm_lines(col = "seashell4", lwd = 1) +
tm_shape(ri_busroutes_sf) +
tm_lines(col = "type", palette = c("purple","red","blue"),
colorNA = NULL, title.col = "Route Type", lwd = 2,
alpha = 0.5) +
tm_shape(I95roadSegment) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I95roadSegment2) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I195roadSegment) +
tm_symbols(shape = I195, border.lwd = NA, size = 0.1) +
tm_shape(I295roadSegment) +
tm_symbols(shape = I295, border.lwd = NA, size = 0.1) +
tm_shape(ri_towns_sf_pts) + tm_dots() +
tm_text("NAME", size = 0.5, col = "black",
xmod = 0.7, ymod = 0.2, shadow = TRUE) +
tm_scale_bar(breaks = c(0, 5, 10), text.size = 0.5,
position = c(0.6,0.005)) +
tm_layout(title = "Rhode Island\nPublic Transit\nAuthority\n(RIPTA)\nBus Routes\nand Population\nDensity",
frame = FALSE, main.title.size = 0.8,
legend.outside = TRUE,
legend.title.size = 0.8,
legend.outside.position = c("right", "top"))
tmap_save(m, "DATA/transport/RI/figures/ri_transit.png",
height = 8, width = 8, units = "in", dpi = 600)
knitr::include_graphics("DATA/transport/RI/figures/ri_transit.png")
```
Approximately `r paste0(round(ri_busAccessPops_df %>% filter(Group == "Total Pop") %>% dplyr::select(PctBus) %>% pull(),1),"%")` of the state population lives within reasonable walking distance of a bus stop (defined as approximately 400 meters or 1/4 mile).
However, this access varies by population group. Figure \@ref(fig:loliBusDist) below compares the percentages of different population groups living within reasonable walking distance of bus stops across the state. Most priority populations, including transit-dependent groups, have access similar to or better than the general population. However, note that people over age 64 have less access on average compared to the general population.
```{r loliBusDist, echo=FALSE, message=FALSE, warning=FALSE, fig.align = "center", fig.cap="Percentage of population groups within 1/4 mile (400 meters) of a bus stop across Rhode Island."}
ri_busAccessPops_df %>%
mutate(Group = recode(Group, "Minority" = "People of Color",
"RI Minority" = "RI POC",
"No HS Dip" = "No HS Diploma")) %>%
ggplot(aes(x = reorder(Group,-PctBus),
y = PctBus)) +
geom_segment(aes(x = reorder(Group,-PctBus), xend = reorder(Group,-PctBus),
y = ri_busAccessPops_df[1,4], yend = PctBus),
color = "skyblue") +
geom_point(color = "blue", size = 4, alpha = 0.8) +
coord_flip() + xlab("") + ylab("") + ggtitle("Rhode Island Populations within Walking Distance (400m) \nof Bus Stops") + theme_light() +
theme(panel.grid.major.y = element_blank(),
panel.border = element_blank(),
axis.ticks.y = element_blank()) +
geom_text(aes(x = Group, y = PctBus + 0.2 * sign(PctBus),
label = paste0(round(PctBus,0),"%")),
hjust = -0.1, vjust = -.8, size = 3,
color=rgb(100,100,100, maxColorValue=255)) +
scale_y_continuous(labels = function(x) paste0(x, "%")) +
geom_hline(yintercept = ri_busAccessPops_df[1,4], linetype = "dashed") +
geom_text(aes(x = "Under 18", y = 69, label = "Above state\naverage"),
color = "gray48") +
geom_text(aes(x = "Under 18", y = 45, label = "Below state\naverage"),
color = "gray48") +
expand_limits(y = c(40,96))
ggsave("images/RI_Bus_graph.png")
```
Specific values of the same can be seen in Table \@ref(tab:statsBusDist) below.
```{r statsBusDist, echo=FALSE, message=FALSE, warning=FALSE, fig.align = "center", fig.cap="Rhode Island populations living within 1/4 mile (400 meters) of a bus stop. Based on ACS 2018 Block Group data."}
# See table of distance by group
ri_busAccessPops_df %>%
mutate(Group = recode(Group, "Minority" = "People of Color",
"RI Minority" = "RI POC",
"No HS Dip" = "No HS Diploma")) %>%
mutate(`% Bus Access` = paste0(round(PctBus,1),"%")) %>%
select(-PctBus) %>%
kableExtra::kable(longtable = T, booktabs = T,
format.args = list(big.mark = ','), align = "r",
caption = "Populations Living within 400m of Bus Stops", col.names = c("Group","RI Pop","Pop with Bus Access","Pct Pop with Bus Access")) %>%
kableExtra::column_spec(3:4, width = "4cm") %>%
kableExtra::kable_styling(latex_options = c("repeat_header"))
```
The population percentages above provide a glimpse of average access to public transit across the state for different population groups. However, access also varies for specific communities. Indeed, it is important to consider vulnerable populations or transportation-limited populations that do not have reasonable access to transit.
```{r TransitNoAccess, include=FALSE}
TransitNoAccess1 <- ri_blkgrps_sf_noBus %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
left_join(., townpopsdf,by="NAME") %>%
group_by(NAME) %>%
summarize(`Block Groups` = n(),
`Over 64` = sum(NewOver64,na.rm = TRUE),
`Pct of Over 64` = round(sum(NewOver64)/max(TotalOver64)*100,1)) %>%
rename("City/Town" = NAME) %>%
mutate(`Pct of Over 64` = paste0(`Pct of Over 64`,"%")) %>%
arrange(desc(`Over 64`))
TransitNoAccess2 <- ri_tracts_sf_noBus %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
left_join(., townpopsdf,by="NAME") %>%
group_by(NAME) %>%
summarize(`Tracts` = n(),
Disabled = sum(NewDisabled,na.rm = TRUE),
`Pct of Disabled` = round(sum(NewDisabled)/max(TotalDisabled)*100,1)) %>%
rename("City/Town" = NAME) %>%
mutate(`Pct of Disabled` = paste0(`Pct of Disabled`,"%")) %>%
arrange(desc(Disabled))
```
Figures \@ref(fig:mapTransitAccessO64) and \@ref(fig:mapTransitAccessDisabled) below highlight developed portions of Census Block Groups and Tracts across Rhode Island which are more than 1 mile from a transit stop and the numbers of persons over 64 or disabled who live there. Tables \@ref(tab:tabTransitAccessO64) and \@ref(tab:tabTransitAccessDisabled) show breakdowns by municipality. For example, Table \@ref(tab:tabTransitAccessO64) shows that `r formatC(as.numeric(TransitNoAccess1[1,3]),big.mark=",")` people over 64 across `r TransitNoAccess1[1,2]` Block Groups in `r TransitNoAccess1[1,1]` resided one or more miles from the nearest transit stop. These people represented `r TransitNoAccess1[1,4]` of people over 64 in `r TransitNoAccess1[1,1]`. Similarly, Table \@ref(tab:tabTransitAccessDisabled) shows that `r formatC(as.numeric(TransitNoAccess2[1,3]),big.mark=",")` people with disabilities across `r TransitNoAccess1[1,2]` Census Tracts in `r TransitNoAccess2[1,1]` resided one or more miles from the nearest transit stop. These people represented `r TransitNoAccess2[1,4]` of people with disabilities in `r TransitNoAccess2[1,1]`.
Maps and tables of other priority populations without access to transit can be found in Appendix B.
```{r mapTransitAccessO64, fig.align = "center", fig.cap="Persons over 64 who are one or more miles from the nearest transit stop by Census Block Group."}
m <- tm_shape(ri_state_sf_cb, unit = "mi") +
tm_fill(col = "gray",alpha = 0.2) +
tm_shape(ri_blkgrps_sf_noBus, unit = "mi") +
tm_fill(col = "NewOver64", alpha = 0.9, style = "quantile",
colorNA = "white", colorNULL = "gray", title = "Number of\nPersons Over 64",
legend.format = list(fun = function(x) formatC(x, digits = 0, format = "f")), palette = "OrRd") +
tm_shape(ri_towns_sf) + tm_borders(alpha = 0.5, lwd = 0.2) +
tm_shape(ne_states_sf_cb) + tm_borders(lwd = 0.2, alpha = 0.8) +
tm_text("STUSPS", size = 0.7, remove.overlap = TRUE, col = "gray") +
tm_shape(ri_highways) + tm_lines(col = "seashell4", lwd = 1) +
# tm_shape(ri_busroutes_sf) +
# tm_lines(col = "type", palette = c("purple","red","blue"),
# colorNA = NULL, title.col = "Route Type", lwd = 2,
# alpha = 0.5) +
tm_shape(ri_busroutes_sf) +
tm_lines(lwd = 2, alpha = 0.5) +
tm_shape(I95roadSegment) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I95roadSegment2) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I195roadSegment) +
tm_symbols(shape = I195, border.lwd = NA, size = 0.1) +
tm_shape(I295roadSegment) +
tm_symbols(shape = I295, border.lwd = NA, size = 0.1) +
tm_shape(ri_towns_sf_pts) + tm_dots() +
tm_text("NAME", size = 0.5, col = "black",
xmod = 0.7, ymod = 0.2, shadow = TRUE) +
tm_scale_bar(breaks = c(0, 5, 10), text.size = 0.5,
position = c(0.6,0.005)) +
tm_add_legend(type = "line", lwd=2, alpha = 0.5, labels = "Transit Route") +
tm_layout(title = "Persons Over 64\n1+ Miles from\nNearest Transit\nStop",
frame = FALSE, main.title.size = 0.8,
legend.outside = TRUE,
legend.title.size = 0.8,
legend.outside.position = c("right", "top"))
tmap_save(m, "DATA/transport/RI/figures/ri_transitO64access.png",
height = 8, width = 8, units = "in", dpi = 600)
knitr::include_graphics("DATA/transport/RI/figures/ri_transitO64access.png")
```
```{r tabTransitAccessO64, fig.align = "center", fig.cap="Persons over 64 in Census Block Groups one or more miles from the nearest bus stop."}
ri_blkgrps_sf_noBus %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
left_join(., townpopsdf,by="NAME") %>%
group_by(NAME) %>%
summarize(`Block Groups` = n(),
`Over 64` = sum(NewOver64,na.rm = TRUE),
`Pct of Over 64` = round(sum(NewOver64)/max(TotalOver64)*100,1)) %>%
rename("City/Town" = NAME) %>%
mutate(`Pct of Over 64` = paste0(`Pct of Over 64`,"%")) %>%
arrange(desc(`Over 64`)) %>%
kableExtra::kable(longtable = T, booktabs = T,
format.args = list(big.mark = ','),
digits = 1,
caption = "Persons Over 64 One or More Miles from Nearest Transit Stop", align = "r",
col.names = c(names(.)[1:2],"Number of Over 64 in Block Groups","Pct of Over 64 in City/Town")) %>%
kableExtra::column_spec(3:4, width = "4cm") %>%
kableExtra::kable_styling(latex_options = c("repeat_header","striped"))
```
```{r mapTransitAccessDisabled, fig.align = "center", fig.cap="Disabled persons who are one or more miles from the nearest transit stop by Census Tract."}
m <- tm_shape(ri_state_sf_cb, unit = "mi") +
tm_fill(col = "gray",alpha = 0.2) +
tm_shape(ri_tracts_sf_noBus, unit = "mi") +
tm_fill(col = "NewDisabled", alpha = 0.9, style = "quantile",
colorNA = "white", colorNULL = "gray", title = "Number of\nDisabled Persons",
legend.format = list(fun = function(x) formatC(x, digits = 0, format = "f")), palette = "OrRd") +
tm_shape(ri_tracts_sf) + tm_borders(alpha = 0.5, lwd = 0.2) +
tm_shape(ne_states_sf_cb) + tm_borders(lwd = 0.2, alpha = 0.8) +
tm_text("STUSPS", size = 0.7, remove.overlap = TRUE, col = "gray") +
tm_shape(ri_highways) + tm_lines(col = "seashell4", lwd = 1) +
# tm_shape(ri_busroutes_sf) +
# tm_lines(col = "type", palette = c("purple","red","blue"),
# colorNA = NULL, title.col = "Route Type", lwd = 2,
# alpha = 0.5) +
tm_shape(ri_busroutes_sf) +
tm_lines(lwd = 2, alpha = 0.5) +
tm_shape(I95roadSegment) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I95roadSegment2) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I195roadSegment) +
tm_symbols(shape = I195, border.lwd = NA, size = 0.1) +
tm_shape(I295roadSegment) +
tm_symbols(shape = I295, border.lwd = NA, size = 0.1) +
tm_shape(ri_towns_sf_pts) + tm_dots() +
tm_text("NAME", size = 0.5, col = "black",
xmod = 0.7, ymod = 0.2, shadow = TRUE) +
tm_scale_bar(breaks = c(0, 5, 10), text.size = 0.5,
position = c(0.6,0.005)) +
tm_add_legend(type = "line", lwd=2, alpha = 0.5, labels = "Transit Route") +
tm_layout(title = "Disabled Persons\n1+ Miles from\nNearest Transit\nStop",
frame = FALSE, main.title.size = 0.8,
legend.outside = TRUE,
legend.title.size = 0.8,
legend.outside.position = c("right", "top"))
tmap_save(m, "DATA/transport/RI/figures/ri_transitDisabledaccess.png",
height = 8, width = 8, units = "in", dpi = 600)
knitr::include_graphics("DATA/transport/RI/figures/ri_transitDisabledaccess.png")
```
```{r tabTransitAccessDisabled, fig.align = "center", fig.cap="Persons over 64 in Census Block Groups one or more miles from the nearest bus stop."}
ri_tracts_sf_noBus %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
left_join(., townpopsdf,by="NAME") %>%
group_by(NAME) %>%
summarize(`Tracts` = n(),
Disabled = sum(NewDisabled,na.rm = TRUE),
`Pct of Disabled` = round(sum(NewDisabled)/max(TotalDisabled)*100,1)) %>%
rename("City/Town" = NAME) %>%
mutate(`Pct of Disabled` = paste0(`Pct of Disabled`,"%")) %>%
arrange(desc(Disabled)) %>%
kableExtra::kable(longtable = T, booktabs = T,
format.args = list(big.mark = ','),
digits = 1,
caption = "Disabled Persons One or More Miles from Nearest Transit Stop", align = "r", col.names = c(names(.)[1:2],"Number of Disabled in Census Tracts","Pct of Disabled in City/Town")) %>%
kableExtra::column_spec(3:4, width = "4cm") %>%
kableExtra::kable_styling(latex_options = c("repeat_header","striped"))
```
## Frequency of Transit Service
The quality of access to public transit can also be assessed by the level or frequency of service, which is measured by "headway." Headway describes the scheduled or observed time between transit vehicle arrivals at a transit stop. For example, a bus route with a 15 minute headway would mean that the bus is scheduled or actually arrives at a given stop four times an hour (it's frequency), or once every 15 minutes. Transit headways are affected by the scheduled frequency of service, the number of vehicles on a given route, traffic delays, and dispatch management of vehicle spacing.[^mindGap] Headways are significant because they affect the desirability and useability of transit service.[^headways] Headways can affect:
* average wait times
* the amount of planning and preparation needed to use transit and stay on schedule
* the amount of time lost when transit schedules do not directly conform to work, school, or activity schedules
* the time penalty for missing a train or bus
* public use or support of transit
Headways are significant for transit dependent populations and can affect the quality of life and economic opportunities of transit riders. Figure \@ref(fig:mapGTFS) below shows average scheduled headways for bus routes throughout Rhode Island.[^headwayReal] Table \@ref(tab:tabGTFS) shows a breakdown of headway times by service type. Headways vary significantly by route and by type of service across the state.
```{r GTFS, include=FALSE}
# Read in RI GTFS data
# # Note that Official Download URL is erratic in availability
# ri_transit <- read_gtfs("https://www.ripta.com/stuff/contentmgr/files/0/3cda81dfa140edbe9aae214b26245b4a/files/google_transit.zip") %>%
# gtfs_as_sf()
# Use previously downloaded GTFS for June 2019
ri_transit <- read_gtfs("DATA/transport/RI/RI_gtfs_files/RIPTA062019gtfs.zip") %>%
gtfs_as_sf()
# add a table to the feed that indicates which service_id runs on which date. This is later useful for linking dates and trips via service_id.
ri_transit <- set_date_service_table(ri_transit)
# To understand service patterns better we need information on weekdays and holidays. With a calendar table we know the weekday and possible holidays for each date.
holidays = tribble(~date, ~holiday,
ymd("2019-07-04"), "Independence Day",
ymd("2019-09-02"), "Labor Day",
ymd("2019-12-25"), "Christmas")
calendar = tibble(date = unique(ri_transit$.$date_service_table$date)) %>%
mutate(
weekday = (function(date) {
c("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday",
"Saturday")[as.POSIXlt(date)$wday + 1]
})(date)
)
calendar <- calendar %>% left_join(holidays, by = "date")
# To analyse on which dates trips run and to group similar services we use service patterns. Such a pattern simply lists all dates a trip runs on. To handle these patterns we create a servicepattern_id using a hash function.
ri_transit <- set_servicepattern(ri_transit)
# Our gtfs feed now contains the data frame service_pattern which links each servicepattern_id to an existing service_id (and by extension trip_id).
# # Understand patterns of service by visualising the data.
# date_servicepattern_table <- ri_transit$.$date_servicepattern_table %>%
# left_join(calendar, by = "date")
#
# ggplot(date_servicepattern_table) + theme_bw() +
# geom_point(aes(x = date, y = servicepattern_id, color = weekday), size = 1) +
# scale_x_date(breaks = scales::date_breaks("1 month")) +
# theme(legend.position = "bottom")
# Use service pattern id for daily M-F service selected based on graphic. CHECK GGPLOT ABOVE TO GET CORRECT SERVICE PATTERN ID!
service_ids <- ri_transit$.$service_pattern %>%
filter(servicepattern_id == "s_fb9e6e7") %>%
pull(service_id)
# now that we’ve identified the set of service_id’s that refer to all weekday trips, we can summarize service between 6 am and 9 pm for bus service on weekdays.
daily_stop_freq <- get_stop_frequency(ri_transit, start_hour = 6, end_hour = 21,
service_ids = service_ids)
# Convert stops to points for mapping
ri_transit_stops_sf <- stops_as_sf(ri_transit$stops)
# Join headway frequencies to stops
ri_transit_stops_sf <- ri_transit_stops_sf %>%
inner_join(daily_stop_freq, by = "stop_id")
# map it out
# tmap_mode("view")
# tm_shape(ri_transit_stops_sf) + tm_dots(col = "headway", alpha = 0.6)
# use the get_route_frequency function to summarise transit service by route, for the same time period.
daily_route_freq <- get_route_frequency(ri_transit, service_ids = service_ids,
start_hour = 6, end_hour = 21)
# Join the route frequencies to geometry for mapping
# get_route_geometry needs a gtfs object that includes shapes as simple feature data frames
ri_routes_sf <- get_route_geometry(ri_transit, service_ids = service_ids)
# join calculated frequencies to geometry
ri_routes_sf <- ri_routes_sf %>%
inner_join(daily_route_freq, by = "route_id")
# Calculate average headway for block groups within walking distance of bus stops and then compute weighted average headway by population group
ri_transit_stopHeadway_df <- ri_transit_stops_sf %>%
st_transform(., crs = 2840) %>%
st_join(., ri_busBuff400m_sf) %>%
as.data.frame() %>%
group_by(GEOID) %>%
summarize(AvgStopHeadway = mean(headway,na.rm = TRUE))
# Create same for tracts
ri_transit_stopHeadwayTracts_df <- ri_transit_stops_sf %>%
st_transform(., crs = 2840) %>%
st_join(., ri_busBuff400mTracts_sf) %>%
as.data.frame() %>%
group_by(GEOID) %>%
summarize(AvgStopHeadway = mean(headway,na.rm = TRUE))
# Create version of ri_transit_stopHeadwayTracts_df for rbind
ri_transit_stopHeadwayTracts <- ri_transit_stopHeadwayTracts_df %>%
as.data.frame() %>%
left_join(ri_busBuff400mTracts_sf,.,by="GEOID") %>%
as.data.frame() %>%
transmute(Disabled = NewDisabled,
`No Car HH` = NewNoCar,
AvgStopHeadway) %>%
gather(key = Group, value = Pop, Disabled:`No Car HH`) %>%
group_by(Group) %>%
summarize(AvgWHeadway = weighted.mean(x = AvgStopHeadway,
w = Pop, na.rm = TRUE))
# Join stop average headway to block groups within buffer
ri_busHeadwayPops_df <- ri_busBuff400m_sf %>%
as.data.frame() %>%
left_join(.,ri_transit_stopHeadway_df, by = "GEOID") %>%
transmute(`Total Pop` = NewPop,
Minority = NewMinority,
`Under 5` = NewUnder5,
`Over 64` = NewOver64,
`Under 18` = NewUnder18,
`English Limited HH` = NewEng_limit,
`Low Income` = NewPov,
`No HS Dip` = NewLths,
`RI Low Income` = NewRI_LOWINC,
`RI Minority` = NewRI_MINORITIES,
AvgStopHeadway) %>%
gather(key = Group, value = Pop, `Total Pop`:`RI Minority`) %>%
group_by(Group) %>%
summarize(AvgWHeadway = weighted.mean(x = AvgStopHeadway,
w = Pop, na.rm = TRUE)) %>%
rbind(.,ri_transit_stopHeadwayTracts)
```
```{r mapGTFS, fig.align = "center", fig.cap="Mean headways by bus route for Rhode Island routes running Monday through Friday, from 6am - 9pm."}
# arrange row order descending so that higher frequency lines are on top
ri_routes_sf <- ri_routes_sf %>%
arrange(desc(mean_headways))
m <- tm_shape(ri_state_sf_cb, unit = "mi") +
tm_fill(col = "gray",alpha = 0.2) +
tm_shape(ne_states_sf_cb) + tm_borders(lwd = 0.2, alpha = 0.8) +
tm_text("STUSPS", size = 0.7, remove.overlap = TRUE, col = "gray") +
tm_shape(ri_highways) + tm_lines(col = "seashell4", lwd = 1) +
tm_shape(ri_routes_sf) +
tm_lines(col = "mean_headways", style = "quantile", lwd = 2, title.col = "Minutes", legend.format = list(fun = function(x) formatC(x, digits = 0, format = "f")), palette = c("#1a9641","#a6d96a","#ffff00","#fdae61","#d7191c")) +
tm_shape(I95roadSegment) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I95roadSegment2) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I195roadSegment) +
tm_symbols(shape = I195, border.lwd = NA, size = 0.1) +
tm_shape(I295roadSegment) +
tm_symbols(shape = I295, border.lwd = NA, size = 0.1) +
tm_shape(ri_towns_sf_pts) + tm_dots() +
tm_text("NAME", size = 0.5, col = "black",
xmod = 0.7, ymod = 0.2, shadow = TRUE) +
tm_scale_bar(breaks = c(0, 5, 10), text.size = 0.5,
position = c(0.6,0.005)) +
tm_layout(title = "Mean\nHeadways\nby Transit\nRoute",
frame = FALSE, main.title.size = 0.8,
legend.outside = TRUE,
legend.title.size = 0.8,
legend.outside.position = c("right", "top"))
tmap_save(m, "DATA/transport/RI/figures/ri_transitHeadways.png",
height = 8, width = 8, units = "in", dpi = 600)
knitr::include_graphics("DATA/transport/RI/figures/ri_transitHeadways.png")
```
```{r tabGTFS, fig.align = "center", fig.cap="Headway by service type for Rhode Island transit based on on GTFS schedule for Monday to Friday service, 6am - 9pm."}
# Show table of mean headways of service type
ri_busroutes_sf %>%
as.data.frame() %>%
mutate(ROUTE = as.character(ROUTE)) %>%
left_join(., as.data.frame(ri_routes_sf), by=c("ROUTE" = "route_id")) %>%
group_by(type) %>%
summarize(Number = n(), Min = min(mean_headways), Mean = mean(mean_headways), Max = max(mean_headways)) %>%
arrange(type) %>%
kableExtra::kable(longtable = T, booktabs = T, digits = 1,
col.names = c("Service Type","Number of Routes",
"Min",
"Mean",
"Max"),
caption = "Headway by Service Type", align = "r") %>%
kableExtra::add_header_above(c(" " = 2, "Headway (minutes)" = 3)) %>%
# kableExtra::column_spec(3:4, width = "4cm") %>%
kableExtra::kable_styling(latex_options = c("repeat_header"))
```
The average population-weighted headway for all transit in the state is `r round(ri_busHeadwayPops_df %>% filter(Group == "Total Pop") %>% select(AvgWHeadway) %>% pull(),1)` minutes. However headways, or service frequencies, vary significantly across population groups. Figure \@ref(fig:loliHeadway) below compares the population-weighted average headways for different groups across the state. Most groups have average headways shorter than the general population. However, persons over age 64 have headways that exceed that of the general population (`r round(ri_busHeadwayPops_df %>% filter(Group == "Over 64") %>% select(AvgWHeadway) %>% pull(),1)` minutes). The shortest population-weighted average headway, experienced by People of Color, as defined by Rhode Island environmental justice policy, is `r round(ri_busHeadwayPops_df %>% arrange(AvgWHeadway) %>% slice(.,1) %>% select(AvgWHeadway) %>% pull(),0)` minutes.
```{r loliHeadway, echo=FALSE, message=FALSE, warning=FALSE, fig.align = "center", fig.cap="Population-weighted average headways for groups within 400 meters of a bus stop across Rhode Island."}
ri_busHeadwayPops_df %>%
mutate(Group = recode(Group, "Minority" = "People of Color",
"RI Minority" = "RI POC",
"No HS Dip" = "No HS Diploma")) %>%
ggplot(aes(x = reorder(Group,AvgWHeadway), y = AvgWHeadway)) +
geom_segment(aes(x = reorder(Group,AvgWHeadway),
xend = reorder(Group,AvgWHeadway),
y = pull(ri_busHeadwayPops_df[8,2]), yend = AvgWHeadway),
color = "tan1") +
geom_point(color = "orange", size = 4, alpha = 0.8) +
coord_flip() + xlab("") + ylab("minutes") + ggtitle("Population-Weighted Average Stop Headway for\nRhode Island Groups within Walking Distance (400m)\nof Bus Stops") + theme_light() +
theme(panel.grid.major.y = element_blank(),
panel.border = element_blank(),
axis.ticks.y = element_blank()) +
geom_text(aes(x = Group, y = AvgWHeadway + 0.2 * sign(AvgWHeadway),
label = round(AvgWHeadway,0)),
hjust = 1.5, vjust = -0.6, size = 3,
color=rgb(100,100,100, maxColorValue=255)) +
geom_hline(yintercept = pull(ri_busHeadwayPops_df[8,2]),
linetype = "dashed") +
geom_text(aes(x = "Under 18", y = 108, label = "Above state\naverage"),
color = "gray48") +
geom_text(aes(x = "Under 18", y = 80, label = "Below state\naverage"),
color = "gray48") +
expand_limits(y = c(60,110))
ggsave("images/RI_BusHdwy_graph.png")
```
```{r excessiveHeadway, include=FALSE}
# Subset block groups and tracts with average headways exceeding 80th percentile headway for all routes
headway80thblkgrps <- ri_busBuff400m_sf %>%
left_join(., ri_transit_stopHeadway_df, by = "GEOID") %>%
filter(AvgStopHeadway >= quantile(ri_routes_sf$mean_headways,0.8))
headway80thtracts <- ri_busBuff400mTracts_sf %>%
left_join(., ri_transit_stopHeadwayTracts_df, by = "GEOID") %>%
filter(AvgStopHeadway >= quantile(ri_routes_sf$mean_headways,0.8))
headway80_1 <- headway80thblkgrps %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
left_join(., townpopsdf,by="NAME") %>%
group_by(NAME) %>%
summarize(`Block Groups` = n(),
`Over 64` = sum(NewOver64,na.rm = TRUE),
`Pct of Over 64` = round(sum(NewOver64)/max(TotalOver64)*100,1)) %>%
rename("City/Town" = NAME) %>%
mutate(`Pct of Over 64` = paste0(`Pct of Over 64`,"%")) %>%
arrange(desc(`Over 64`))
headway80_2 <- headway80thtracts %>%
st_centroid(.) %>%
st_intersection(ri_towns_sf,.) %>%
as.data.frame() %>%
left_join(., townpopsdf,by="NAME") %>%
group_by(NAME) %>%
summarize(`Tracts` = n(),
Disabled = sum(NewDisabled,na.rm = TRUE),
`Pct of Disabled` = round(sum(NewDisabled)/max(TotalDisabled)*100,1)) %>%
rename("City/Town" = NAME) %>%
mutate(`Pct of Disabled` = paste0(`Pct of Disabled`,"%")) %>%
arrange(desc(Disabled))
# write out to file for use in later analysis
save(headway80thblkgrps, headway80thtracts,
ri_busHeadwayPops_df, ri_transit_stopHeadway_df,
file = "DATA/transport/RI/headway80th.Rds")
st_write(headway80thblkgrps,"DATA/transport/RI/headway80thblkgrps_bus.shp",
delete_layer = TRUE)
st_write(headway80thtracts, "DATA/transport/RI/headway80thtracts_bus.shp",
delete_layer = TRUE)
```
The population-weighted average headways above provide a glimpse of average headways across the state for different population groups. However, headways also vary for specific communities. Indeed, it is important to consider priority populations or transportation-limited populations that experience excessively long headways or low service frequency. Figures \@ref(fig:mapHeadwayOver64) and \@ref(fig:mapHeadwayDisabled) below highlight communities of persons over 64 or disabled persons within walking distance of transit stops (i.e., 400m or 1/4 mile), but where the mean headway for these stops exceeds the 80th percentile of mean route headways for the state (`r quantile(ri_routes_sf$mean_headways,0.8)` minutes). Tables \@ref(tab:tabHeadwayOver64) and \@ref(tab:tabHeadwayDisabled) show breakdowns by municipality. For example, Table \@ref(tab:tabHeadwayOver64) shows that `r formatC(as.numeric(headway80_1[1,3]),big.mark=",")` people over 64 across `r headway80_1[1,2]` Block Groups in `r headway80_1[1,1]` resided in areas where the average headway of accessible transit stops exceeded `r quantile(ri_routes_sf$mean_headways,0.8)` minutes. These people represented `r headway80_1[1,4]` of people over 64 in `r headway80_1[1,1]`. Similarly, Table \@ref(tab:tabHeadwayDisabled) shows that `r formatC(as.numeric(headway80_2[1,3]),big.mark=",")` people with disabilities across `r headway80_2[1,2]` Census Tracts in `r headway80_2[1,1]` resided in areas where the average headway of accessible transit stops exceeded `r quantile(ri_routes_sf$mean_headways,0.8)` minutes. These people represented `r headway80_2[1,4]` of people with disabilities in `r headway80_2[1,1]`.
Maps and tables of other priority populations with excessive headways can be found in Appendix B.
```{r mapHeadwayOver64, fig.align = "center", fig.cap="Persons over 64 within 400m or 1/4 mile of transit stops in which the mean headway for these stops is above the 80th percentile for the state."}
m <- tm_shape(ri_state_sf_cb, unit = "mi") +
tm_fill(col = "gray",alpha = 0.2) +
tm_shape(headway80thblkgrps) +
tm_fill(col = "NewOver64", alpha = 0.9, style = "quantile",
colorNA = "white", colorNULL = "gray", title = "Number of\nPersons Over 64",
legend.format = list(fun = function(x) formatC(x, digits = 0, format = "f")), palette = "OrRd") +
tm_shape(ri_towns_sf) + tm_borders(alpha = 0.5, lwd = 0.2) +
tm_shape(ne_states_sf_cb) + tm_borders(lwd = 0.2, alpha = 0.8) +
tm_text("STUSPS", size = 0.7, remove.overlap = TRUE, col = "gray") +
tm_shape(ri_highways) + tm_lines(col = "seashell4", lwd = 1) +
# tm_shape(ri_busroutes_sf) +
# tm_lines(col = "type", palette = c("purple","red","blue"),
# colorNA = NULL, title.col = "Route Type", lwd = 2,
# alpha = 0.5) +
tm_shape(ri_busroutes_sf) + tm_lines(lwd = 1, alpha = 0.3) +
tm_shape(I95roadSegment) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I95roadSegment2) +
tm_symbols(shape = I95, border.lwd = NA, size = 0.1) +
tm_shape(I195roadSegment) +
tm_symbols(shape = I195, border.lwd = NA, size = 0.1) +
tm_shape(I295roadSegment) +
tm_symbols(shape = I295, border.lwd = NA, size = 0.1) +
tm_shape(ri_towns_sf_pts) + tm_dots() +
tm_text("NAME", size = 0.5, col = "black",