-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathextract_outputs.R
5384 lines (5060 loc) · 177 KB
/
extract_outputs.R
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
# Script that extracts output from VE-State
library(visioneval)
ematmodel <- openModel(getwd())
ematmodelresults <- ematmodel$results()
ModelName <- ematmodel$modelName
DatastoreName <- file.path(ematmodelresults$Results[[ModelName]]$resultsPath, ematmodel$setting("DatastoreName"))
DatastoreType <- ematmodel$setting("DatastoreType")
Ma <- unique(ematmodelresults$Results[[ModelName]]$ModelState()$Geo$Marea)
Az <- unique(ematmodelresults$Results[[ModelName]]$ModelState()$Geo$Azone)
Years <- ematmodel$RunParam_ls$Years
# Create an output directory if one doesn't exist
output_path <- file.path(ematmodelresults$Results[[ModelName]]$resultsPath, "output")
if(!dir.exists(output_path)){
dir.create(output_path)
}
#==============================================================
#Define function to calculate metropolitan performance measures
#==============================================================
calcMetropolitanMeasures <-
function(Year, Ma, DstoreLocs_ = c("Datastore"), DstoreType = "RD") {
#Prepare for datastore queries
#-----------------------------
QPrep_ls <- prepareForDatastoreQuery(
DstoreLocs_ = DstoreLocs_,
DstoreType = DstoreType
)
#Define function to create a data frame of measures
#--------------------------------------------------
makeMeasureDataFrame <- function(DataNames_, Ma) {
if (length(Ma) > 1) {
Data_XMa <- t(sapply(DataNames_, function(x) get(x)))
} else {
Data_XMa <- t(t(sapply(DataNames_, function(x) get(x))))
}
colnames(Data_XMa) <- Ma
Measures_ <- gsub("_Ma", "", DataNames_)
Units_ <-
unname(sapply(DataNames_, function(x) attributes(get(x))$Units))
Description_ <-
unname(sapply(DataNames_, function(x) attributes(get(x))$Description))
Data_df <- cbind(
Measure = Measures_,
data.frame(Data_XMa),
Units = Units_,
Description = Description_
)
rownames(Data_df) <- NULL
Data_df
}
#=========================
#HOUSEHOLD CHARACTERISTICS
#=========================
#Number of households in Marea
#-----------------------------
MareaHhNum_Ma <- summarizeDatasets(
Expr = "count(HhSize)",
Units_ = c(
HhSize = "",
Marea = ""),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhNum_Ma <- MareaHhNum_Ma[match(Ma, MareaHhNum_Ma$Marea),"Measure"]
attributes(MareaHhNum_Ma) <-
list(Units = "Households",
Description = "Number of households residing in Marea")
#Population of Marea
#-------------------
MareaHhPop_Ma <- summarizeDatasets(
Expr = "sum(HhSize)",
Units_ = c(
HhSize = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhPop_Ma <- MareaHhPop_Ma[match(Ma, MareaHhPop_Ma$Marea), "Measure"]
attributes(MareaHhPop_Ma) <-
list(Units = "Persons",
Description = "Number of persons residing in Marea")
#Number of workers in Marea
#--------------------------
MareaHhWorkers_Ma <- summarizeDatasets(
Expr = "sum(Workers)",
Units_ = c(
Workers = "PRSN",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhWorkers_Ma <- MareaHhWorkers_Ma[match(Ma, MareaHhWorkers_Ma$Marea), "Measure"]
attributes(MareaHhWorkers_Ma) <-
list(Units = "Workers",
Description = "Number of workers residing in Marea")
#Total household income of Marea
#-------------------------------
MareaHhIncome_Ma <- summarizeDatasets(
Expr = "sum(Income)",
Units_ = c(
Income = "USD",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhIncome_Ma <- MareaHhIncome_Ma[match(Ma, MareaHhIncome_Ma$Marea), "Measure"]
attributes(MareaHhIncome_Ma) <-
list(Units = "Base year dollars",
Description = "Total annual income of households residing in Marea")
#Number of drivers in Marea
#--------------------------
MareaHhDrivers_Ma <- summarizeDatasets(
Expr = "sum(Drivers)",
Units_ = c(
Drivers = "PRSN",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhDrivers_Ma <- MareaHhDrivers_Ma[match(Ma, MareaHhDrivers_Ma$Marea), "Measure"]
attributes(MareaHhDrivers_Ma) <-
list(Units = "Drivers",
Description = "Number of drivers residing in Marea")
#Number of vehicles owned by households in Marea
#-----------------------------------------------
MareaHhVehicles_Ma <- summarizeDatasets(
Expr = "sum(NumAuto) + sum(NumLtTrk)",
Units_ = c(
NumAuto = "VEH",
NumLtTrk = "VEH",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhVehicles_Ma <- MareaHhVehicles_Ma[match(Ma, MareaHhVehicles_Ma$Marea), "Measure"]
attributes(MareaHhVehicles_Ma) <-
list(Units = "Household light-duty vehicles",
Description = "Total number of light-duty vehicles owned/leased by households residing in Marea")
#Marea number of light trucks
#----------------------------
MareaHhLightTrucks_Ma <- summarizeDatasets(
Expr = "sum(NumLtTrk)",
Units_ = c(
NumLtTrk = "VEH",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhLightTrucks_Ma <- MareaHhLightTrucks_Ma[match(Ma, MareaHhLightTrucks_Ma$Marea), "Measure"]
#Marea light-truck vehicle proportion
#------------------------------------
MareaHhLtTrkProp_Ma <- MareaHhLightTrucks_Ma / MareaHhVehicles_Ma
attributes(MareaHhLtTrkProp_Ma) <-
list(Units = "Light truck proportion of household vehicles",
Description = "Light truck proportion of light-duty vehicles owned/leased by households residing in the Marea")
#Average household vehicle age for Marea
#---------------------------------------
MareaHhAveVehAge_Ma <- summarizeDatasets(
Expr = "mean(Age[VehicleAccess == 'Own'])",
Units_ = c(
Age = "YR",
VehicleAccess = "",
Marea = ""
),
By_ = "Marea",
Table = "Vehicle",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhAveVehAge_Ma <- MareaHhAveVehAge_Ma[match(Ma, MareaHhAveVehAge_Ma$Marea), "Measure"]
attributes(MareaHhAveVehAge_Ma) <-
list(Units = "Years",
Description = "Average age of vehicles owned/leased by households residing in the Marea")
#Average car service light truck proportion of car service DVMT
#--------------------------------------------------------------
MareaCarSvcLtTrkDvmtProp_Ma <- summarizeDatasets(
Expr = "sum(DvmtProp[VehicleAccess != 'Own' & Type == 'LtTrk']) / sum(DvmtProp[VehicleAccess != 'Own'])",
Units_ = c(
DvmtProp = "",
VehicleAccess = "",
Type = "",
Marea = ""
),
By_ = "Marea",
Table = "Vehicle",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaCarSvcLtTrkDvmtProp_Ma <- MareaCarSvcLtTrkDvmtProp_Ma[match(Ma, MareaCarSvcLtTrkDvmtProp_Ma$Marea), "Measure"]
attributes(MareaCarSvcLtTrkDvmtProp_Ma) <-
list(Units = "Proportion",
Description = "Average proportion car service vehicle DVMT in light trucks used by households residing in the Marea")
#Average car service vehicle age for Marea
#-----------------------------------------
MareaCarSvcAveVehAge_Ma <- summarizeDatasets(
Expr = "mean(Age[VehicleAccess != 'Own'])",
Units_ = c(
Age = "YR",
VehicleAccess = "",
Marea = ""
),
By_ = "Marea",
Table = "Vehicle",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaCarSvcAveVehAge_Ma <- MareaCarSvcAveVehAge_Ma[match(Ma, MareaCarSvcAveVehAge_Ma$Marea), "Measure"]
attributes(MareaCarSvcAveVehAge_Ma) <-
list(Units = "Years",
Description = "Average age of car service vehicles used by households residing in the Marea")
#Average commercial service vehicle light truck proportion
#---------------------------------------------------------
MareaComSvcLtTrkDvmtProp <- summarizeDatasets(
Expr = "ComSvcLtTrkProp",
Units_ = c(
ComSvcLtTrkProp = ""
),
Table = "Region",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaComSvcLtTrkDvmtProp <- MareaComSvcLtTrkDvmtProp[,"Measure"]
MareaComSvcLtTrkDvmtProp_Ma <- rep(MareaComSvcLtTrkDvmtProp, length(Ma))
attributes(MareaComSvcLtTrkDvmtProp_Ma) <-
list(Units = "Proportion",
Description = "Light truck proportion of commercial service vehicle DVMT in the Marea")
rm(MareaComSvcLtTrkDvmtProp)
#Average commercial service vehicle age
#--------------------------------------
MareaComSvcAveVehAge <- summarizeDatasets(
Expr = "AveComSvcVehicleAge",
Units_ = c(
AveComSvcVehicleAge = "YR"
),
Table = "Region",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaComSvcAveVehAge <- MareaComSvcAveVehAge[,"Measure"]
MareaComSvcAveVehAge_Ma <- rep(MareaComSvcAveVehAge, length(Ma))
attributes(MareaComSvcAveVehAge_Ma) <-
list(Units = "Years",
Description = "Average age of commercial service vehicles used in the Marea")
rm(MareaComSvcAveVehAge)
#Number of households in urbanized area
#--------------------------------------
HhNum_Ma <- summarizeDatasets(
Expr = "count(HhSize[LocType == 'Urban'])",
Units_ = c(
HhSize = "",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhNum_Ma <- HhNum_Ma[match(Ma, HhNum_Ma$Marea), "Measure"]
attributes(HhNum_Ma) <-
list(Units = "Households",
Description = "Number of households residing in urbanized area")
#Population in urbanized area
#----------------------------
HhPop_Ma <- summarizeDatasets(
Expr = "sum(HhSize[LocType == 'Urban'])",
Units_ = c(
HhSize = "",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhPop_Ma <- HhPop_Ma[match(Ma, HhPop_Ma$Marea), "Measure"]
attributes(HhPop_Ma) <-
list(Units = "Persons",
Description = "Number of persons residing in urbanized area")
#Average household size of urbanized area households
#---------------------------------------------------
HhAveSize_Ma <- HhPop_Ma / HhNum_Ma
#Number of workers
#-----------------
HhWorkers_Ma <- summarizeDatasets(
Expr = "sum(Workers[LocType == 'Urban'])",
Units_ = c(
Workers = "PRSN",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhWorkers_Ma <- HhWorkers_Ma[match(Ma, HhWorkers_Ma$Marea), "Measure"]
attributes(HhWorkers_Ma) <-
list(Units = "Workers",
Description = "Number of workers residing in urbanized area")
#Average workers per household
#-----------------------------
HhAveNumWkr_Ma <- HhWorkers_Ma / HhNum_Ma
#Total household income
#----------------------
HhIncome_Ma <- summarizeDatasets(
Expr = "sum(Income[LocType == 'Urban'])",
Units_ = c(
Income = "USD",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhIncome_Ma <- HhIncome_Ma[match(Ma, HhIncome_Ma$Marea), "Measure"]
attributes(HhIncome_Ma) <-
list(Units = "Base year dollars",
Description = "Total annual income of households residing in urbanized area")
#Average income per household
#----------------------------
HhAveIncPerHh_Ma <- HhIncome_Ma / HhNum_Ma
attributes(HhAveIncPerHh_Ma) <-
list(Units = "Base year dollars per household",
Description = "Average annual income of households residing in urbanized area")
#Average income per person
#-------------------------
HhAveIncPerPrsn_Ma <- HhIncome_Ma / HhPop_Ma
attributes(HhAveIncPerPrsn_Ma) <-
list(Units = "Base year dollars per person",
Description = "Average annual income per person of households residing in urbanized area")
#Average income per worker
#-------------------------
HhAveIncPerWkr_Ma <- HhIncome_Ma / HhWorkers_Ma
attributes(HhAveIncPerWkr_Ma) <-
list(Units = "Base year dollars per worker",
Description = "Average annual income per worker of households residing in urbanized area")
#Number of drivers
#-----------------
HhDrivers_Ma <- summarizeDatasets(
Expr = "sum(Drivers[LocType == 'Urban'])",
Units_ = c(
Drivers = "PRSN",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhDrivers_Ma <- HhDrivers_Ma[match(Ma, HhDrivers_Ma$Marea), "Measure"]
attributes(HhDrivers_Ma) <-
list(Units = "Drivers",
Description = "Number of drivers residing in urbanized area")
#Average number of drivers per household
#---------------------------------------
HhAveDvrPerHh_Ma <- HhDrivers_Ma / HhNum_Ma
attributes(HhAveDvrPerHh_Ma) <-
list(Units = "Drivers per household",
Description = "Average number of drivers in households residing in urbanized area")
#Average number of drivers per person
#------------------------------------
HhAveDvrPerPrsn_Ma <- HhDrivers_Ma / HhPop_Ma
attributes(HhAveDvrPerPrsn_Ma) <-
list(Units = "Drivers per person",
Description = "Average number of drivers per person residing in urbanized area")
#Average number of drivers per worker
#------------------------------------
HhAveDvrPerWkr_Ma <- HhDrivers_Ma / HhWorkers_Ma
attributes(HhAveDvrPerWkr_Ma) <-
list(Units = "Drivers per worker",
Description = "Average number of drivers per worker residing in urbanized area")
#Number of vehicles
#------------------
HhVehicles_Ma <- summarizeDatasets(
Expr = "sum(NumAuto[LocType == 'Urban']) + sum(NumLtTrk[LocType == 'Urban'])",
Units_ = c(
NumAuto = "VEH",
NumLtTrk = "VEH",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhVehicles_Ma <- HhVehicles_Ma[match(Ma, HhVehicles_Ma$Marea),"Measure"]
attributes(HhVehicles_Ma) <-
list(Units = "Household light-duty vehicles",
Description = "Total number of light-duty vehicles owned/leased by households residing in urbanized area")
#Average number of vehicles per household
#----------------------------------------
HhAveVehPerHh_Ma <- HhVehicles_Ma / HhNum_Ma
attributes(HhAveVehPerHh_Ma) <-
list(Units = "Household light-duty vehicles per household",
Description = "Average number of light-duty vehicles owned/leased by households residing in urbanized area")
#Average number of vehicles per person
#-------------------------------------
HhAveVehPerPrsn_Ma <- HhVehicles_Ma / HhPop_Ma
attributes(HhAveVehPerPrsn_Ma) <-
list(Units = "Household light-duty vehicles per person",
Description = "Average number of household light-duty vehicles per person residing in urbanized area")
#Average number of vehicles per worker
#-------------------------------------
HhAveVehPerWkr_Ma <- HhVehicles_Ma / HhWorkers_Ma
attributes(HhAveVehPerWkr_Ma) <-
list(Units = "Household light-duty vehicles per worker",
Description = "Average number of household light-duty vehicles per worker residing in urbanized area")
#Average number of vehicles per driver
#-------------------------------------
HhAveVehPerDvr_Ma <- HhVehicles_Ma / HhDrivers_Ma
attributes(HhAveVehPerDvr_Ma) <-
list(Units = "Household light-duty vehicles per driver",
Description = "Average number of household light-duty vehicles per driver residing in urbanized area")
#Number of light trucks
#----------------------
HhLightTrucks_Ma <- summarizeDatasets(
Expr = "sum(NumLtTrk[LocType == 'Urban'])",
Units_ = c(
NumLtTrk = "VEH",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhLightTrucks_Ma <- HhLightTrucks_Ma[match(Ma, HhLightTrucks_Ma$Marea),"Measure"]
#Light-truck vehicle proportion
#------------------------------
HhLtTrkProp_Ma <- HhLightTrucks_Ma / HhVehicles_Ma
attributes(HhLtTrkProp_Ma) <-
list(Units = "Light truck proportion of household vehicles",
Description = "Light truck proportion of light-duty vehicles owned/leased by households residing in urbanized area")
#Total daily work parking cost
#-----------------------------
HhTotDailyWkrParkingCost_Ma <- summarizeDatasets(
Expr = "sum(ParkingCost[LocType == 'Urban'])",
Units_ = c(
ParkingCost = "",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = list(
Worker = c("ParkingCost"),
Household = c("Marea", "LocType")
),
Key = "HhId",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhTotDailyWkrParkingCost_Ma <- HhTotDailyWkrParkingCost_Ma[match(Ma, HhTotDailyWkrParkingCost_Ma$Marea), "Measure"]
attributes(HhTotDailyWkrParkingCost_Ma) <-
list(Units = "USD per day",
Description = "Total daily work parking expenditures by households living in the urbanized portion of the Marea")
#Total daily non-work parking cost
#---------------------------------
HhTotDailyOthParkingCost_Ma <- summarizeDatasets(
Expr = "sum(OtherParkingCost[LocType == 'Urban'])",
Units = c(
OtherParkingCost = "",
LocType = "",
Marea = ""
),
By_ = "Marea",
Table = "Household",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhTotDailyOthParkingCost_Ma <- HhTotDailyOthParkingCost_Ma[match(Ma, HhTotDailyOthParkingCost_Ma$Marea), "Measure"]
attributes(HhTotDailyOthParkingCost_Ma) <-
list(Units = "USD per day",
Description = "Total daily non-work parking expenditures by households living in the urbanized portion of the Marea")
#Average daily household parking cost
#------------------------------------
HhAveDailyParkingCost_Ma <-
(HhTotDailyWkrParkingCost_Ma + HhTotDailyOthParkingCost_Ma) / HhNum_Ma
attributes(HhAveDailyParkingCost_Ma) <-
list(Units = "USD per day",
Description = "Average daily parking expenditures by households living in the urbanized portion of the Marea")
#Proportion of households that have reduced car ownership due to use of car services
#-----------------------------------------------------------------------------------
#All households
PropHhReduceVehicleOwnership_Ma <- summarizeDatasets(
Expr = "sum(OwnCostSavings > 0 & LocType == 'Urban') / count(OwnCostSavings[LocType == 'Urban'])",
Units = c(
OwnCostSavings = "",
LocType = "",
Marea = ""
),
Table = list(
Household = c("OwnCostSavings", "Marea"),
Bzone = c("LocType")
),
By_ = "Marea",
Key = "Bzone",
Group = Year,
QueryPrep_ls = QPrep_ls
)
PropHhReduceVehicleOwnership_Ma <- PropHhReduceVehicleOwnership_Ma[match(Ma, PropHhReduceVehicleOwnership_Ma$Marea), "Measure"]
attributes(PropHhReduceVehicleOwnership_Ma) <-
list(Units = "proportion of households",
Description = "Proportion of households living in the urbanized portion of the Marea that reduce vehicle ownership due to car service availability")
#Households in high density (>= 10,000 persons per square mile)
PropHhHiDenReduceVehicleOwnership_Ma <- summarizeDatasets(
Expr = "sum(OwnCostSavings > 0 & LocType == 'Urban' & D1B >= 10000) / count(OwnCostSavings[LocType == 'Urban' & D1B >= 10000])",
Units = c(
OwnCostSavings = "",
LocType = "",
Marea = "",
D1B = "PRSN/SQMI"
),
Table = list(
Household = c("OwnCostSavings", "Marea"),
Bzone = c("LocType", "D1B")
),
By_ = "Marea",
Key = "Bzone",
Group = Year,
QueryPrep_ls = QPrep_ls
)
PropHhHiDenReduceVehicleOwnership_Ma <- PropHhHiDenReduceVehicleOwnership_Ma[match(Ma, PropHhHiDenReduceVehicleOwnership_Ma$Marea), "Measure"]
attributes(PropHhHiDenReduceVehicleOwnership_Ma) <-
list(Units = "proportion of households",
Description = "Proportion of households living in the high density urbanized portion of the Marea that reduce vehicle ownership due to car service availability")
#Households in medium density (>= 4,000 & < 10,000 persons per square mile)
PropHhMedDenReduceVehicleOwnership_Ma <- summarizeDatasets(
Expr = "sum(OwnCostSavings > 0 & LocType == 'Urban' & D1B >= 4000 & D1B < 10000) / count(OwnCostSavings[LocType == 'Urban' & D1B >= 4000 & D1B < 10000])",
Units = c(
OwnCostSavings = "",
LocType = "",
Marea = "",
D1B = "PRSN/SQMI"
),
Table = list(
Household = c("OwnCostSavings", "Marea"),
Bzone = c("LocType", "D1B")
),
By_ = "Marea",
Key = "Bzone",
Group = Year,
QueryPrep_ls = QPrep_ls
)
PropHhMedDenReduceVehicleOwnership_Ma <- PropHhMedDenReduceVehicleOwnership_Ma[match(Ma, PropHhMedDenReduceVehicleOwnership_Ma$Marea), "Measure"]
attributes(PropHhMedDenReduceVehicleOwnership_Ma) <-
list(Units = "proportion of households",
Description = "Proportion of households living in the medium density urbanized portion of the Marea that reduce vehicle ownership due to car service availability")
#Proportion of households that have high level car service available to them
#---------------------------------------------------------------------------
PropHhWithHiCarSvc_Ma <- summarizeDatasets(
Expr = "sum(NumHh[CarSvcLevel == 'High' & LocType == 'Urban']) / sum(NumHh[LocType == 'Urban'])",
Units = c(
NumHh = "",
CarSvcLevel = "",
LocType = "",
Marea = ""
),
Table = "Bzone",
By_ = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
PropHhWithHiCarSvc_Ma <- PropHhWithHiCarSvc_Ma[match(Ma, PropHhWithHiCarSvc_Ma$Marea), "Measure"]
attributes(PropHhWithHiCarSvc_Ma) <-
list(Units = "proportion of households",
Description = "Proportion of households living in Bzones in the urbanized portion of the Marea that have high car service availability")
#Data frame of household characteristics
#---------------------------------------
HhCharacteristics_df <- makeMeasureDataFrame(
DataNames_ = c(
"MareaHhNum_Ma",
"MareaHhPop_Ma",
"MareaHhWorkers_Ma",
"MareaHhIncome_Ma",
"MareaHhDrivers_Ma",
"MareaHhVehicles_Ma",
"MareaHhLtTrkProp_Ma",
"MareaHhAveVehAge_Ma",
"MareaCarSvcLtTrkDvmtProp_Ma",
"MareaCarSvcAveVehAge_Ma",
"MareaComSvcLtTrkDvmtProp_Ma",
"MareaComSvcAveVehAge_Ma",
"HhNum_Ma",
"HhPop_Ma",
"HhAveSize_Ma",
"HhWorkers_Ma",
"HhAveNumWkr_Ma",
"HhIncome_Ma",
"HhAveIncPerHh_Ma",
"HhAveIncPerPrsn_Ma",
"HhAveIncPerWkr_Ma",
"HhVehicles_Ma",
"HhAveVehPerHh_Ma",
"HhAveVehPerPrsn_Ma",
"HhAveVehPerWkr_Ma",
"HhAveVehPerDvr_Ma",
"HhLtTrkProp_Ma",
"HhTotDailyWkrParkingCost_Ma",
"HhTotDailyOthParkingCost_Ma",
"HhAveDailyParkingCost_Ma",
"PropHhReduceVehicleOwnership_Ma",
"PropHhHiDenReduceVehicleOwnership_Ma",
"PropHhMedDenReduceVehicleOwnership_Ma",
"PropHhWithHiCarSvc_Ma"
),
Ma = Ma
)
#============================
#Daily Vehicle Miles Traveled
#============================
#Marea commercial service vehicle DVMT
#-------------------------------------
MareaComSvcDvmt_Ma <- summarizeDatasets(
Expr = "sum(ComSvcUrbanDvmt + ComSvcTownDvmt + ComSvcRuralDvmt)",
Units = c(
ComSvcUrbanDvmt = "MI/DAY",
ComSvcTownDvmt = "MI/DAY",
ComSvcRuralDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaComSvcDvmt_Ma <- MareaComSvcDvmt_Ma[match(Ma, MareaComSvcDvmt_Ma$Marea), "Measure"]
attributes(MareaComSvcDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Commercial service vehicle daily vehicle miles traveled attributable to the demand of households and businesses located in the Marea"
)
#Marea public transit 'van' DVMT
#-------------------------------
MareaVanDvmt_Ma <- summarizeDatasets(
Expr = "sum(VanDvmt)",
Units = c(
VanDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaVanDvmt_Ma <- MareaVanDvmt_Ma[match(Ma, MareaVanDvmt_Ma$Marea), "Measure"]
attributes(MareaVanDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Daily vehicle miles traveled by on-demand transit vans in the Marea."
)
#Marea household DVMT
#--------------------
MareaHhDvmt_Ma <- summarizeDatasets(
Expr = "sum(UrbanHhDvmt + TownHhDvmt + RuralHhDvmt)",
Units_ = c(
UrbanHhDvmt = "MI/DAY",
TownHhDvmt = "MI/DAY",
RuralHhDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaHhDvmt_Ma <- MareaHhDvmt_Ma[match(Ma, MareaHhDvmt_Ma$Marea), "Measure"]
attributes(MareaHhDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Daily vehicle miles traveled by households residing in the Marea"
)
#Marea light-duty vehicle DVMT
#-----------------------------
MareaLdvDvmt_Ma <- MareaHhDvmt_Ma + MareaVanDvmt_Ma + MareaComSvcDvmt_Ma
attributes(MareaLdvDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Sum of daily vehicle miles traveled by households residing in the Marea, commercial service travel attributable to the demand of Marea households and businesses, and on-demand transit van travel in the Marea."
)
#Marea car service proportion of household DVMT
#----------------------------------------------
MareaCarSvcPropHhDvmt_Ma <- summarizeDatasets(
Expr = "sum(Dvmt[VehicleAccess != 'Own'] * DvmtProp[VehicleAccess != 'Own']) / sum(Dvmt * DvmtProp)",
Units = c(
Dvmt = "",
VehicleAccess = "",
DvmtProp = "",
Marea = ""
),
By_ <- "Marea",
Table = list(
Household = c("Dvmt", "Marea"),
Vehicle = c("VehicleAccess", "DvmtProp")
),
Key = "HhId",
Group = Year,
QueryPrep_ls = QPrep_ls
)
MareaCarSvcPropHhDvmt_Ma <- MareaCarSvcPropHhDvmt_Ma[match(Ma, MareaCarSvcPropHhDvmt_Ma$Marea), "Measure"]
attributes(MareaCarSvcPropHhDvmt_Ma) <- list(
Units = "Proportion of DVMT",
Description = "Proportion of the DVMT of households residing in the Marea using car services"
)
#Urbanized area car service proportion of household DVMT
#-------------------------------------------------------
CarSvcPropHhDvmt_Ma <- summarizeDatasets(
Expr = "sum(Dvmt[VehicleAccess != 'Own' & LocType == 'Urban'] * DvmtProp[VehicleAccess != 'Own' & LocType == 'Urban']) / sum(Dvmt[LocType == 'Urban'] * DvmtProp[LocType == 'Urban'])",
Units = c(
Dvmt = "",
VehicleAccess = "",
DvmtProp = "",
Marea = "",
LocType = ""
),
By_ <- "Marea",
Table = list(
Household = c("Dvmt", "Marea", "LocType"),
Vehicle = c("VehicleAccess", "DvmtProp")
),
Key = "HhId",
Group = Year,
QueryPrep_ls = QPrep_ls
)
CarSvcPropHhDvmt_Ma <- CarSvcPropHhDvmt_Ma[match(Ma, CarSvcPropHhDvmt_Ma$Marea), "Measure"]
attributes(CarSvcPropHhDvmt_Ma) <- list(
Units = "Proportion of DVMT",
Description = "Proportion of the DVMT of households residing in the urbanized area using car services"
)
#Urbanized area commercial service vehicle DVMT
#----------------------------------------------
ComSvcDvmt_Ma <- summarizeDatasets(
Expr = "sum(ComSvcUrbanDvmt)",
Units = c(
ComSvcUrbanDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
ComSvcDvmt_Ma <- ComSvcDvmt_Ma[match(Ma, ComSvcDvmt_Ma$Marea), "Measure"]
attributes(ComSvcDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Commercial service vehicle daily vehicle miles traveled attributable to the demand of households and businesses located in the urbanized area"
)
#Urbanized area public transit 'van' DVMT
#----------------------------------------
VanDvmt_Ma <- summarizeDatasets(
Expr = "sum(VanDvmt)",
Units = c(
VanDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
VanDvmt_Ma <- VanDvmt_Ma[match(Ma, VanDvmt_Ma$Marea), "Measure"]
attributes(VanDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Daily vehicle miles traveled by on-demand transit vans in the urbanized area."
)
#Urbanized area household DVMT
#-----------------------------
HhDvmt_Ma <- summarizeDatasets(
Expr = "sum(UrbanHhDvmt)",
Units = c(
UrbanHhDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
HhDvmt_Ma <- HhDvmt_Ma[match(Ma, HhDvmt_Ma$Marea), "Measure"]
attributes(HhDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Daily vehicle miles traveled by households residing in the urbanized area"
)
#Urbanized area light-duty vehicle DVMT
#--------------------------------------
LdvDvmt_Ma <- HhDvmt_Ma + VanDvmt_Ma + ComSvcDvmt_Ma
attributes(LdvDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Sum of daily vehicle miles traveled by households residing in the urbanized area, commercial service travel attributable to the demand of urbanized area households and businesses, and on-demand transit van travel in the urbanized area."
)
#Urban roadway light-duty vehicle DVMT
#-------------------------------------
LdvRoadDvmt_Ma <- summarizeDatasets(
Expr = "sum(LdvFwyDvmt + LdvArtDvmt + LdvOthDvmt)",
Units = c(
LdvFwyDvmt = "MI/DAY",
LdvArtDvmt = "MI/DAY",
LdvOthDvmt = "MI/DAY",
Marea = ""
),
By_ = "Marea",
Table = "Marea",
Group = Year,
QueryPrep_ls = QPrep_ls
)
LdvRoadDvmt_Ma <- LdvRoadDvmt_Ma[match(Ma, LdvRoadDvmt_Ma$Marea), "Measure"]
attributes(LdvRoadDvmt_Ma) <- list(
Units = "Miles per day",
Description = "Daily vehicle miles traveled by light-duty vehicles on roadways within the urbanized area"
)
#Urbanized area household DVMT per household
#-------------------------------------------
AveHhDvmtPerHh_Ma <- HhDvmt_Ma / HhNum_Ma
attributes(AveHhDvmtPerHh_Ma) <- list(
Units = "Miles per day per household",
Description = "Average daily vehicle miles traveled per household residing within the urbanized area"
)
#Urbanized area household DVMT per person
#----------------------------------------
AveHhDvmtPerPrsn_Ma <- HhDvmt_Ma / HhPop_Ma
attributes(AveHhDvmtPerHh_Ma) <- list(
Units = "Miles per day per person",
Description = "Average daily household vehicle miles of households residing within the urbanized area per person"
)
#Urbanized area household DVMT per driver
#----------------------------------------
AveHhDvmtPerDvr_Ma <- HhDvmt_Ma / HhDrivers_Ma
attributes(AveHhDvmtPerDvr_Ma) <- list(
Units = "Miles per day per driver",
Description = "Average daily household vehicle miles of households residing within the urbanized area per driver"
)
#Urbanized area household DVMT per vehicle
#-----------------------------------------
AveHhDvmtPerVeh_Ma <- HhDvmt_Ma / HhVehicles_Ma
attributes(AveHhDvmtPerVeh_Ma) <- list(
Units = "Miles per day per vehicle",
Description = "Average daily household vehicle miles of households residing within the urbanized area per household vehicle"
)
#Urbanized area light-duty vehicle DVMT per household
#----------------------------------------------------
AveLdvDvmtPerHh_Ma <- LdvDvmt_Ma / HhNum_Ma
attributes(AveLdvDvmtPerHh_Ma) <- list(
Units = "Miles per day per household",
Description = "Average of all daily light-duty vehicle miles traveled attributable to urbanized area households and businesses per household"
)
#Urbanized area light-duty vehicle DVMT per person
#-------------------------------------------------
AveLdvDvmtPerPrsn_Ma <- LdvDvmt_Ma / HhPop_Ma
attributes(AveLdvDvmtPerPrsn_Ma) <- list(
Units = "Miles per day per person",
Description = "Average of all daily light-duty vehicle miles traveled attributable to urbanized area households and businesses per person"
)
#Urbanized area light-duty vehicle DVMT per driver
#-------------------------------------------------
AveLdvDvmtPerDvr_Ma <- LdvDvmt_Ma / HhDrivers_Ma
attributes(AveLdvDvmtPerDvr_Ma) <- list(
Units = "Miles per day per driver",
Description = "Average of all daily light-duty vehicle miles traveled attributable to urbanized area households and businesses per driver"
)
#Urbanized area light-duty vehicle DVMT per vehicle
#--------------------------------------------------
AveLdvDvmtPerVeh_Ma <- LdvDvmt_Ma / HhVehicles_Ma
attributes(AveLdvDvmtPerVeh_Ma) <- list(
Units = "Miles per day per vehicle",
Description = "Average of all daily light-duty vehicle miles traveled attributable to urbanized area households and businesses per vehicle"
)
#Ratio of urbanized area household DVMT to light-duty DVMT
#---------------------------------------------------------
PropHhDvmt_Ma <- HhDvmt_Ma / LdvDvmt_Ma
attributes(PropHhDvmt_Ma) <- list(
Units = "Proportion of LDV DVMT",
Description = "Household DVMT proportion of light-duty vehicle DVMT attributable to urbanized area households and businesses"
)
#Ratio of urbanized area commercial service DVMT to light-duty DVMT
#------------------------------------------------------------------
PropComSvcDvmt_Ma <- ComSvcDvmt_Ma / LdvDvmt_Ma
attributes(PropComSvcDvmt_Ma) <- list(
Units = "Proportion of LDV DVMT",
Description = "Commercial service DVMT proportion of light-duty vehicle DVMT attributable to urbanized area households and businesses"
)
#Ratio of urbanized area public transit van DVMT to light-duty DVMT
#------------------------------------------------------------------
PropVanDvmt_Ma <- VanDvmt_Ma / LdvDvmt_Ma
PropComSvcDvmt_Ma <- ComSvcDvmt_Ma / LdvDvmt_Ma
attributes(PropVanDvmt_Ma) <- list(
Units = "Proportion of LDV DVMT",
Description = "Public transit van DVMT proportion of light-duty vehicle DVMT attributable to urbanized area households and businesses"
)
#Data frame of DVMT values
#-------------------------
Dvmt_df <- makeMeasureDataFrame(
DataNames_ = c(
"MareaHhDvmt_Ma",
"MareaComSvcDvmt_Ma",
"MareaVanDvmt_Ma",
"MareaLdvDvmt_Ma",
"MareaCarSvcPropHhDvmt_Ma",
"HhDvmt_Ma",
"ComSvcDvmt_Ma",
"VanDvmt_Ma",
"LdvDvmt_Ma",
"LdvRoadDvmt_Ma",
"AveHhDvmtPerHh_Ma",
"AveHhDvmtPerPrsn_Ma",
"AveHhDvmtPerDvr_Ma",
"AveHhDvmtPerVeh_Ma",
"AveLdvDvmtPerHh_Ma",