GeoJSON file
toronto_neighbourhoods.json
Dataset for Q2 of 2018
toronto-neighbourhoods-2018-2-All-MonthlyAggregate.csv
uber_nbds <- st_read("./toronto_neighbourhoods.json", stringsAsFactors=FALSE)
Reading layer `toronto_neighbourhoods' from data source `C:\Users\14165\Desktop\github notebooks\TTS\toronto_neighbourhoods.json' using driver `GeoJSON'
Simple feature collection with 141 features and 2 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: -79.63926 ymin: 43.581 xmax: -79.11524 ymax: 43.85546
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs
str(uber_nbds)
Classes ‘sf’ and 'data.frame': 141 obs. of 3 variables:
$ MOVEMENT_ID : chr "1" "2" "3" "4" ...
$ DISPLAY_NAME: chr "York University Busway, York University Heights, North York, Toronto" "0 Hambly Avenue, The Beach, Old Toronto, Toronto" "3400 Kingston Road, Scarborough Village, Scarborough, Toronto" "100 Dunn Avenue, Parkdale, Old Toronto, Toronto" ...
$ geometry :sfc_MULTIPOLYGON of length 141; first list element: List of 1
..$ :List of 1
.. ..$ : num [1:530, 1:2] -79.5 -79.5 -79.5 -79.5 -79.5 ...
..- attr(*, "class")= chr "XY" "MULTIPOLYGON" "sfg"
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA
..- attr(*, "names")= chr "MOVEMENT_ID" "DISPLAY_NAME"
uber_nbds$ID <- as.integer(uber_nbds$MOVEMENT_ID)
uber_nbds$DISPLAY_NAME
[1] "York University Busway, York University Heights, North York, Toronto"
[2] "0 Hambly Avenue, The Beach, Old Toronto, Toronto"
[3] "3400 Kingston Road, Scarborough Village, Scarborough, Toronto"
[4] "100 Dunn Avenue, Parkdale, Old Toronto, Toronto"
[5] "0 Carlaw Avenue, Leslieville, Old Toronto, Toronto"
[6] "0 Acheson Boulevard, Port Union, Scarborough, Toronto"
[7] "2800 Kingston Road, Cliffcrest, Scarborough, Toronto"
[8] "0 Guildwood Parkway, Guildwood, Scarborough, Toronto"
[9] "0 Avenue of the Island, Old Toronto, Toronto"
[10] "4200 Lawrence Avenue East, West Hill, Scarborough, Toronto"
[11] "400 Grandstand Entrance Road, Rexdale, Etobicoke, Toronto"
[12] "100 Isabella Street, Downtown, Old Toronto, Toronto"
[13] "0 Rangoon Road, Eringate - Centennial - West Deane, Etobicoke, Toronto"
[14] "0 Duncairn Road, Don Mills, North York, Toronto"
[15] "0 McIntosh Street, Cliffside, Scarborough, Toronto"
[16] "300 Old Finch Avenue, Rouge, Scarborough, Toronto"
[17] "100 Fairlawn Avenue, Bedford Park, Old Toronto, Toronto"
[18] "100 Lascelles Boulevard, Midtown Toronto, Old Toronto, Toronto"
[19] "0 Station Road, Mimico, Etobicoke, Toronto"
[20] "100 Augusta Avenue, Downtown, Old Toronto, Toronto"
[21] "0 Norwood Road, Upper Beaches, Old Toronto, Toronto"
[22] "0 Pondsview Drive, Pleasant View, North York, Toronto"
[23] "500 Manning Avenue, Palmerston, Old Toronto, Toronto"
[24] "0 Brushwood Court, Parkwoods - Donalda, North York, Toronto"
[25] "0 Dolly Varden Boulevard, Woburn, Scarborough, Toronto"
[26] "0 Balmoral Avenue, Midtown Toronto, Old Toronto, Toronto"
[27] "0 Eaton Avenue, Riverdale, Old Toronto, Toronto"
[28] "0 Liscombe Road, Rustic, North York, Toronto"
[29] "0 Massey Square, Old East York, East York, Toronto"
[30] "0 Carlton Street, Downtown, Old Toronto, Toronto"
[31] "100 Wareside Road, Etobicoke West Mall, Etobicoke, Toronto"
[32] "1000 Dundas Street West, Trinity - Bellwoods, Old Toronto, Toronto"
[33] "0 Lappin Avenue, Wallace Emerson, Old Toronto, Toronto"
[34] "0 Ashbury Avenue, Oakwood Village, York, Toronto"
[35] "100 Rockwell Avenue, Earlscourt, Old Toronto, Toronto"
[36] "300 Horsham Avenue, Willowdale, North York, Toronto"
[37] "100 Eighth Street, New Toronto, Etobicoke, Toronto"
[38] "200 Lumsden Avenue, Woodbine - Lumsden, East York, Toronto"
[39] "100 Glengrove Avenue West, Midtown Toronto, Old Toronto, Toronto"
[40] "0 Densley Avenue, Brookhaven - Amesbury, North York, Toronto"
[41] "200 Saint Clarens Avenue, Brockton Village, Old Toronto, Toronto"
[42] "0 Erie Street, Maple Leaf, North York, Toronto"
[43] "1700 Gerrard Street East, Beach Hill, Old Toronto, Toronto"
[44] "200 Johnston Avenue, Lansing, North York, Toronto"
[45] "0 Apex Road, Yorkdale, North York, Toronto"
[46] "Mimico Creek Trail, Etobicoke, Toronto"
[47] "0 Navenby Crescent, Humber Summit, North York, Toronto"
[48] "0 Grenoble Drive, Flemingdon Park, North York, Toronto"
[49] "300 Bay Mills Boulevard, Tam O'Shanter, Scarborough, Toronto"
[50] "0 Ionview Road, Ionview, Scarborough, Toronto"
[51] "0 Allcroft Drive, Rexdale, Etobicoke, Toronto"
[52] "0 West Toronto Street, The Junction, York, Toronto"
[53] "100 Thorncliffe Park Drive, Thorncliffe Park, East York, Toronto"
[54] "500 Mortimer Avenue, Woodbine Heights, East York, Toronto"
[55] "0 Strathearn Road, Midtown Toronto, York, Toronto"
[56] "5300 Dundas Street West, Islington - City Centre West, Etobicoke, Toronto"
[57] "0 Chieftain Crescent, St. Andrew - Windfields, North York, Toronto"
[58] "0 Habitant Drive, Emery, North York, Toronto"
[59] "0 Cosburn Avenue, Old East York, East York, Toronto"
[60] "0 Leagrove Crescent, Clairlea, Scarborough, Toronto"
[61] "200 Linden Avenue, Kennedy Park, Scarborough, Toronto"
[62] "0 Nairn Avenue, Earlscourt, York, Toronto"
[63] "0 Abinger Crescent, Princess - Rosethorn, Etobicoke, Toronto"
[64] "500 Spadina Road, Midtown Toronto, Old Toronto, Toronto"
[65] "0 Sparkhall Avenue, Riverdale, Old Toronto, Toronto"
[66] "600 Roselawn Avenue, Midtown Toronto, Old Toronto, Toronto"
[67] "100 Donald Avenue, Silverthorn, York, Toronto"
[68] "100 Eddystone Avenue, Jane and Finch, North York, Toronto"
[69] "100 Torbrick Road, East Danforth, Old Toronto, Toronto"
[70] "1700 Eglinton Avenue East, North York, Toronto"
[71] "0 Corwin Crescent, Wilson Heights, North York, Toronto"
[72] "Finch Corridor Recreational Trail, Newtonbrook, North York, Toronto"
[73] "0 Maple Branch Path, Kingsview Village, Etobicoke, Toronto"
[74] "0 Beardmore Crescent, Newtonbrook, North York, Toronto"
[75] "0 Glenfield Crescent, Woodbine Gardens, East York, Toronto"
[76] "0 Evelyn Avenue, High Park North, Old Toronto, Toronto"
[77] "0 Four Oaks Gate, Old East York, East York, Toronto"
[78] "200 Russell Hill Road, Midtown Toronto, Old Toronto, Toronto"
[79] "0 Queen Marys Drive, The Kingsway, Etobicoke, Toronto"
[80] "500 Windermere Avenue, Runnymede, Old Toronto, Toronto"
[81] "100 Parkway Forest Drive, Henry Farm, North York, Toronto"
[82] "100 Hazelton Avenue, Midtown Toronto, Old Toronto, Toronto"
[83] "0 Chudleigh Road, Fairbank, York, Toronto"
[84] "0 Fabian Place, Humber Heights - Westmount, Etobicoke, Toronto"
[85] "100 Sorauren Avenue, Parkdale, Old Toronto, Toronto"
[86] "Wyatt Avenue, Downtown, Old Toronto, Toronto"
[87] "100 Saint George Street, University, Old Toronto, Toronto"
[88] "0 Loganberry Crescent, Hillcrest Village, North York, Toronto"
[89] "0 Emmett Avenue, Mount Dennis, York, Toronto"
[90] "1400 Kennedy Road, Dorset Park, Scarborough, Toronto"
[91] "0 Darlingbrook Crescent, Edenbridge - Humber Valley, Etobicoke, Toronto"
[92] "300 Connaught Avenue, Newtonbrook, North York, Toronto"
[93] "0 East Liberty Street, Liberty Village, Old Toronto, Toronto"
[94] "400 Todd Baylis Boulevard, Beechborough - Greenbrook, North York, Toronto"
[95] "200 Ellis Avenue, Swansea, Old Toronto, Toronto"
[96] "400 Jones Avenue, Riverdale, Old Toronto, Toronto"
[97] "0 Calverley Trail, Highland Creek, Scarborough, Toronto"
[98] "5000 Finch Avenue East, Agincourt, Scarborough, Toronto"
[99] "100 Newport Avenue, Oakridge, Scarborough, Toronto"
[100] "0 Scholfield Avenue, Midtown Toronto, Old Toronto, Toronto"
[101] "1900 Lawrence Avenue East, Wexford, Scarborough, Toronto"
[102] "2500 Midland Avenue, Agincourt, Scarborough, Toronto"
[103] "0 Trudelle Street, Eglinton East, Scarborough, Toronto"
[104] "0 Briarglen Court, Bridlewood, Scarborough, Toronto"
[105] "0 Cove Drive, Rexdale, Etobicoke, Toronto"
[106] "0 Ridgevale Drive, Englemount - Lawrence, North York, Toronto"
[107] "100 Wilmington Avenue, Bathurst Manor, North York, Toronto"
[108] "400 Rimilton Avenue, Alderwood, Etobicoke, Toronto"
[109] "1200 Brimley Road, Bendale, Scarborough, Toronto"
[110] "0 Genthorn Avenue, Rexdale, Etobicoke, Toronto"
[111] "100 Garratt Boulevard, Downsview, North York, Toronto"
[112] "0 Raymond Avenue, Lambton Baby Point, York, Toronto"
[113] "Saint Basil Lane, Bay Cloverhill, Old Toronto, Toronto"
[114] "0 Secroft Crescent, Black Creek, North York, Toronto"
[115] "200 Princess Avenue, Willowdale, North York, Toronto"
[116] "0 Silverstone Drive, Rexdale, Etobicoke, Toronto"
[117] "300 Passmore Avenue, Armdale, Scarborough, Toronto"
[118] "Yen Lane, Downtown, Old Toronto, Toronto"
[119] "0 Forman Avenue, Midtown Toronto, Old Toronto, Toronto"
[120] "0 Belsize Drive, Midtown Toronto, Old Toronto, Toronto"
[121] "0 Wallasey Avenue, Humberlea, North York, Toronto"
[122] "0 Playter Boulevard, The Danforth, Old Toronto, Toronto"
[123] "0 Callowhill Drive, Richview, Etobicoke, Toronto"
[124] "0 Tally Lane, Bayview Village, North York, Toronto"
[125] "300 Brooke Avenue, Nortown, North York, Toronto"
[126] "0 Goodview Road, Don Valley Village, North York, Toronto"
[127] "400 Rockcliffe Boulevard, Rockcliffe - Smythe, York, Toronto"
[128] "200 Queen Street East, Downtown, Old Toronto, Toronto"
[129] "0 Braemore Gardens, Midtown Toronto, Old Toronto, Toronto"
[130] "400 Lawrence Avenue East, Scarborough, Toronto"
[131] "0 Macdonald Avenue, Weston, York, Toronto"
[132] "100 Gladstone Avenue, Little Portugal, Old Toronto, Toronto"
[133] "0 Ash Crescent, Long Branch, Etobicoke, Toronto"
[134] "100 Wedgewood Drive, Newtonbrook, North York, Toronto"
[135] "100 Mammoth Hall Trail, Malvern, Scarborough, Toronto"
[136] "200 Mill Road, Markland Wood, Etobicoke, Toronto"
[137] "0 Treerun Avenue, Milliken, Scarborough, Toronto"
[138] "0 Livonia Place, Morningside, Scarborough, Toronto"
[139] "0 Rolph Road, Leaside, East York, Toronto"
[140] "900 York Beltline Trail, Briar Hill - Belgravia, York, Toronto"
[141] "Water's Edge Promenade, Downtown, Old Toronto, Toronto"
Bay Street Corridor is City of Toronto Neighbourhood 76. This is Uber Neighbourhood 113. We hold fixed this neighbourhood and examine travel times whose destination is to this neighbourhood.
uber_movement <- fread("toronto-neighbourhoods-2018-2-All-MonthlyAggregate.csv")
str(uber_movement)
Classes ‘data.table’ and 'data.frame': 54366 obs. of 7 variables:
$ sourceid : int 3 135 15 18 53 14 46 16 130 51 ...
$ dstid : int 65 21 130 100 11 140 4 120 123 31 ...
$ month : int 5 5 5 5 5 5 5 5 5 5 ...
$ mean_travel_time : num 1675 1861 1778 467 2087 ...
$ standard_deviation_travel_time : num 388 424 413 288 800 ...
$ geometric_mean_travel_time : num 1635 1815 1732 379 1984 ...
$ geometric_standard_deviation_travel_time: num 1.24 1.25 1.26 2.02 1.35 1.42 1.66 1.35 1.48 1.38 ...
- attr(*, ".internal.selfref")=<externalptr>
uber_source_113 <- uber_movement[dstid == 113, .(MEAN_TRIP_DURATION = mean(mean_travel_time)), by = .(ID = sourceid)]
str(uber_source_113)
Classes ‘data.table’ and 'data.frame': 141 obs. of 2 variables:
$ ID : int 131 68 54 109 105 4 119 51 110 88 ...
$ MEAN_TRIP_DURATION: num 2260 2583 1163 1880 1927 ...
- attr(*, ".internal.selfref")=<externalptr>
Robin Lovelace, Jakub Nowosad, and Jannes Muenchow, Geocomputation with R. Chapter 3: Attribute data operations
uber_source_113_nbds <- left_join(uber_nbds, uber_source_113, by = "ID")
str(uber_source_113_nbds)
Classes ‘sf’ and 'data.frame': 141 obs. of 5 variables:
$ MOVEMENT_ID : chr "1" "2" "3" "4" ...
$ DISPLAY_NAME : chr "York University Busway, York University Heights, North York, Toronto" "0 Hambly Avenue, The Beach, Old Toronto, Toronto" "3400 Kingston Road, Scarborough Village, Scarborough, Toronto" "100 Dunn Avenue, Parkdale, Old Toronto, Toronto" ...
$ ID : int 1 2 3 4 5 6 7 8 9 10 ...
$ MEAN_TRIP_DURATION: num 2235 941 2259 899 612 ...
$ geometry :sfc_MULTIPOLYGON of length 141; first list element: List of 1
..$ :List of 1
.. ..$ : num [1:530, 1:2] -79.5 -79.5 -79.5 -79.5 -79.5 ...
..- attr(*, "class")= chr "XY" "MULTIPOLYGON" "sfg"
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA
..- attr(*, "names")= chr "MOVEMENT_ID" "DISPLAY_NAME" "ID" "MEAN_TRIP_DURATION"
ggplot(uber_source_113_nbds) +
geom_sf(aes(fill = MEAN_TRIP_DURATION), color = "white") +
labs(title = "Mean Travel Time of Trips to Bay Street Corridor, 2018 Q2") +
scale_fill_viridis(option="magma", name="Seconds", direction=-1)
plot(uber_nbds[113,1])
Playter Estates-Danforth is City of Toronto Neighbourhood 67 and Uber Movement Neighbourhood 122.
uber_source_122 <- uber_movement[dstid == 122, .(MEAN_TRIP_DURATION = mean(mean_travel_time)), by = .(ID = sourceid)]
uber_source_122_nbds <- left_join(uber_nbds, uber_source_122, by = "ID")
ggplot(uber_source_122_nbds) +
geom_sf(aes(fill = MEAN_TRIP_DURATION), color = "white") +
labs(title = "Mean Travel Time of Trips to Playter Estates-Danforth, 2018 Q2") +
scale_fill_viridis(option="magma", name="Seconds", direction=-1)
plot(uber_nbds[122,1])
Data Management Group, University of Toronto Transportation Research Institute
2016 TTS, City of Toronto: http://www.dmg.utoronto.ca/csv/tts/tts2016_ward_Toronto.csv
Government of Ontario, Transportation Tomorrow historical survey data
tts_dataset.zip
1986 TTS, 1991 TTS, 1996 TTS, 2001 TTS, 2006 TTS, 2011 TTS, 2016 TTS
TTS2016_csv <- fread("tts2016_ward_Toronto.csv")
str(TTS2016_csv)
Classes ‘data.table’ and 'data.frame': 419 obs. of 46 variables:
$ Region : chr "Total Number of households" "Number of houses" "Number of apartments" "Number of townhouses" ...
$ Toronto: chr "1112970" "343197" "704502" "65271" ...
$ Ward 1 : chr "17876" "5607" "10049" "2220" ...
$ Ward 2 : chr "20025" "8047" "10628" "1350" ...
$ Ward 3 : chr "20081" "10098" "8798" "1185" ...
$ Ward 4 : chr "21460" "10060" "10716" "684" ...
$ Ward 5 : chr "30650" "11774" "17741" "1135" ...
$ Ward 6 : chr "32584" "9256" "21946" "1382" ...
$ Ward 7 : chr "17181" "7190" "8713" "1278" ...
$ Ward 8 : chr "17926" "3614" "11596" "2716" ...
$ Ward 9 : chr "16466" "7321" "8449" "696" ...
$ Ward 10: chr "25736" "7386" "17803" "547" ...
$ Ward 11: chr "24924" "8551" "15243" "1130" ...
$ Ward 12: chr "21407" "7825" "13394" "188" ...
$ Ward 13: chr "26523" "9023" "16673" "827" ...
$ Ward 14: chr "25279" "3928" "20494" "857" ...
$ Ward 15: chr "23780" "7706" "15123" "951" ...
$ Ward 16: chr "21412" "11570" "9685" "157" ...
$ Ward 17: chr "17706" "8982" "7562" "1162" ...
$ Ward 18: chr "22614" "3417" "17795" "1402" ...
$ Ward 19: chr "33809" "4736" "26232" "2841" ...
$ Ward 20: chr "52384" "2269" "48583" "1532" ...
$ Ward 21: chr "22825" "6566" "15619" "640" ...
$ Ward 22: chr "36313" "7100" "28551" "662" ...
$ Ward 23: chr "42571" "9863" "30910" "1798" ...
$ Ward 24: chr "25796" "9136" "15058" "1602" ...
$ Ward 25: chr "24009" "12025" "10868" "1116" ...
$ Ward 26: chr "25593" "4372" "20390" "831" ...
$ Ward 27: chr "51060" "3397" "46278" "1385" ...
$ Ward 28: chr "41607" "1137" "38415" "2055" ...
$ Ward 29: chr "20537" "9094" "11199" "244" ...
$ Ward 30: chr "24213" "8069" "13558" "2586" ...
$ Ward 31: chr "21776" "9248" "12010" "518" ...
$ Ward 32: chr "24770" "10873" "12474" "1423" ...
$ Ward 33: chr "22817" "6132" "13936" "2749" ...
$ Ward 34: chr "23338" "5986" "15192" "2160" ...
$ Ward 35: chr "23976" "7963" "14257" "1756" ...
$ Ward 36: chr "21169" "9972" "10387" "810" ...
$ Ward 37: chr "23052" "10278" "11361" "1413" ...
$ Ward 38: chr "24574" "7689" "15961" "924" ...
$ Ward 39: chr "16945" "6649" "8106" "2190" ...
$ Ward 40: chr "25342" "6857" "15741" "2744" ...
$ Ward 41: chr "19253" "10855" "5991" "2407" ...
$ Ward 42: chr "22136" "10218" "6923" "4995" ...
$ Ward 43: chr "19469" "7160" "10705" "1604" ...
$ Ward 44: chr "20009" "14199" "3390" "2420" ...
- attr(*, ".internal.selfref")=<externalptr>
- [55] “Total Number of persons”
- [79] “Number of persons without a driver’s licence”
- [80] “Number of persons with a driver’s licence”
- [84] “Number of persons with a TTC metro pass”
- [85] “Number of persons without any transit pass”
- [147] “Total number of trips made by residents in 24-hour”
- [156] “Number of trips by residents by walk mode in 24-hour”
- [157] “Number of trips by residents by bicycle in 24-hour”
- [416] “Number of transit trips made by residents with TTC Subway/RT”
- [417] “Number of transit trips made by residents with TTC Bus/Streetcar”
TTS2016_selected <- TTS2016_csv[c(55,79,80,84,85,147,156,157,416,417),]
TTS2016_transpose <- transpose(TTS2016_selected)
v <- as.vector(as.matrix(TTS2016_transpose)[1,])
str(v)
chr [1:10] "Total Number of persons" "Number of persons without a driver's licence" ...
TTS2016_table <- TTS2016_transpose[-c(1:2),]
colnames(TTS2016_table) <- v
TTS2016_df <- as.data.frame(TTS2016_table)
for (y in v){
TTS2016_df[,y] <- as.numeric(TTS2016_df[, y])
}
str(TTS2016_df)
'data.frame': 44 obs. of 10 variables:
$ Total Number of persons : num 58143 57366 52165 54630 69706 ...
$ Number of persons without a driver's licence : num 25473 22845 15209 17131 20624 ...
$ Number of persons with a driver's licence : num 31764 33277 36399 36443 47950 ...
$ Number of persons with a TTC metro pass : num 5584 4608 3764 5569 8292 ...
$ Number of persons without any transit pass : num 47216 45986 44290 44886 51767 ...
$ Total number of trips made by residents in 24-hour : num 89018 100340 110739 114533 153310 ...
$ Number of trips by residents by walk mode in 24-hour : num 10159 4003 5242 3892 8371 ...
$ Number of trips by residents by bicycle in 24-hour : num 242 265 850 665 1683 ...
$ Number of transit trips made by residents with TTC Subway/RT : num 6468 7344 11422 12012 28552 ...
$ Number of transit trips made by residents with TTC Bus/Streetcar: num 16396 17390 14248 17510 18839 ...
TTS2016_df$SCODE_NAME <- c(1:44)
str(TTS2016_df)
'data.frame': 44 obs. of 11 variables:
$ Total Number of persons : num 58143 57366 52165 54630 69706 ...
$ Number of persons without a driver's licence : num 25473 22845 15209 17131 20624 ...
$ Number of persons with a driver's licence : num 31764 33277 36399 36443 47950 ...
$ Number of persons with a TTC metro pass : num 5584 4608 3764 5569 8292 ...
$ Number of persons without any transit pass : num 47216 45986 44290 44886 51767 ...
$ Total number of trips made by residents in 24-hour : num 89018 100340 110739 114533 153310 ...
$ Number of trips by residents by walk mode in 24-hour : num 10159 4003 5242 3892 8371 ...
$ Number of trips by residents by bicycle in 24-hour : num 242 265 850 665 1683 ...
$ Number of transit trips made by residents with TTC Subway/RT : num 6468 7344 11422 12012 28552 ...
$ Number of transit trips made by residents with TTC Bus/Streetcar: num 16396 17390 14248 17510 18839 ...
$ SCODE_NAME : int 1 2 3 4 5 6 7 8 9 10 ...
TTS2016_df$TRIPS_PER_DAY <- TTS2016_df$`Total number of trips made by residents in 24-hour`/
TTS2016_df$`Total Number of persons`
TTS2016_df$DRIVERS_LICENCE <- TTS2016_df$`Number of persons with a driver's licence`/
TTS2016_df$`Total Number of persons`
TTS2016_df$TTC_PASS <- TTS2016_df$`Number of persons with a TTC metro pass`/
TTS2016_df$`Total Number of persons`
TTS2016_df$WALKS_PER_DAY <- TTS2016_df$`Number of trips by residents by walk mode in 24-hour`/
TTS2016_df$`Total Number of persons`
TTS2016_df$BIKES_PER_DAY <- TTS2016_df$`Number of trips by residents by bicycle in 24-hour`/
TTS2016_df$`Total Number of persons`
wards <- st_read("C:/Users/14165/Desktop/Shapefiles/May2010_WGS84/icitw_wgs84.shp", stringsAsFactors=FALSE)
Reading layer `icitw_wgs84' from data source `C:\Users\14165\Desktop\Shapefiles\May2010_WGS84\icitw_wgs84.shp' using driver `ESRI Shapefile'
Simple feature collection with 44 features and 10 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: -79.63927 ymin: 43.58101 xmax: -79.11525 ymax: 43.85547
epsg (SRID): 4326
proj4string: +proj=longlat +datum=WGS84 +no_defs
str(wards)
Classes ‘sf’ and 'data.frame': 44 obs. of 11 variables:
$ GEO_ID : int 14630026 14630028 14630024 14630027 14630035 14630029 14630036 14630037 14630039 14630031 ...
$ CREATE_ID : int 63519 63519 63519 63519 63519 63519 63519 63519 63519 63519 ...
$ NAME : chr "Scarborough-Rouge River (41)" "Scarborough East (44)" "Scarborough-Rouge River (42)" "Scarborough-Agincourt (39)" ...
$ SCODE_NAME: chr "41" "44" "42" "39" ...
$ LCODE_NAME: chr "EA41" "EA44" "EA42" "EA39" ...
$ TYPE_DESC : chr "Ward" "Ward" "Ward" "Ward" ...
$ TYPE_CODE : chr "CITW" "CITW" "CITW" "CITW" ...
$ OBJECTID : int 1 2 3 4 5 6 7 8 9 10 ...
$ SHAPE_AREA: num 0 0 0 0 0 0 0 0 0 0 ...
$ SHAPE_LEN : num 0 0 0 0 0 0 0 0 0 0 ...
$ geometry :sfc_POLYGON of length 44; first list element: List of 1
..$ : num [1:410, 1:2] -79.3 -79.3 -79.3 -79.3 -79.3 ...
..- attr(*, "class")= chr "XY" "POLYGON" "sfg"
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA
..- attr(*, "names")= chr "GEO_ID" "CREATE_ID" "NAME" "SCODE_NAME" ...
wards$SCODE_NAME <- as.integer(wards$SCODE_NAME)
TTS2016_wards <- left_join(wards, TTS2016_df, by = "SCODE_NAME")
str(TTS2016_wards)
Classes ‘sf’ and 'data.frame': 44 obs. of 26 variables:
$ GEO_ID : int 14630026 14630028 14630024 14630027 14630035 14630029 14630036 14630037 14630039 14630031 ...
$ CREATE_ID : int 63519 63519 63519 63519 63519 63519 63519 63519 63519 63519 ...
$ NAME : chr "Scarborough-Rouge River (41)" "Scarborough East (44)" "Scarborough-Rouge River (42)" "Scarborough-Agincourt (39)" ...
$ SCODE_NAME : int 41 44 42 39 24 40 33 23 8 38 ...
$ LCODE_NAME : chr "EA41" "EA44" "EA42" "EA39" ...
$ TYPE_DESC : chr "Ward" "Ward" "Ward" "Ward" ...
$ TYPE_CODE : chr "CITW" "CITW" "CITW" "CITW" ...
$ OBJECTID : int 1 2 3 4 5 6 7 8 9 10 ...
$ SHAPE_AREA : num 0 0 0 0 0 0 0 0 0 0 ...
$ SHAPE_LEN : num 0 0 0 0 0 0 0 0 0 0 ...
$ Total Number of persons : num 62727 60284 74745 50098 63305 ...
$ Number of persons without a driver's licence : num 22154 19940 29530 15588 18475 ...
$ Number of persons with a driver's licence : num 38138 39345 43774 32474 43038 ...
$ Number of persons with a TTC metro pass : num 5506 4224 7331 4577 9396 ...
$ Number of persons without any transit pass : num 51887 46662 61305 42118 48477 ...
$ Total number of trips made by residents in 24-hour : num 100898 118075 131976 84997 123751 ...
$ Number of trips by residents by walk mode in 24-hour : num 6792 6594 7408 6116 6549 ...
$ Number of trips by residents by bicycle in 24-hour : num 487 438 365 518 681 ...
$ Number of transit trips made by residents with TTC Subway/RT : num 9317 6974 10692 7824 23544 ...
$ Number of transit trips made by residents with TTC Bus/Streetcar: num 18141 15936 25233 13444 18686 ...
$ TRIPS_PER_DAY : num 1.61 1.96 1.77 1.7 1.95 ...
$ DRIVERS_LICENCE : num 0.608 0.653 0.586 0.648 0.68 ...
$ TTC_PASS : num 0.0878 0.0701 0.0981 0.0914 0.1484 ...
$ WALKS_PER_DAY : num 0.1083 0.1094 0.0991 0.1221 0.1035 ...
$ BIKES_PER_DAY : num 0.00776 0.00727 0.00488 0.01034 0.01076 ...
$ geometry :sfc_POLYGON of length 44; first list element: List of 1
..$ : num [1:410, 1:2] -79.3 -79.3 -79.3 -79.3 -79.3 ...
..- attr(*, "class")= chr "XY" "POLYGON" "sfg"
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
..- attr(*, "names")= chr "GEO_ID" "CREATE_ID" "NAME" "SCODE_NAME" ...
ggplot(TTS2016_wards) +
geom_sf(aes(fill = `Total Number of persons`), color = "white") +
labs(title = "Total Number of persons by Ward, Toronto 2016")
ggplot(TTS2016_wards) +
geom_sf(aes(fill = TRIPS_PER_DAY), color = "white") +
labs(title = "Average daily trips per residents by Ward, Toronto 2016")
ggplot(TTS2016_wards) +
geom_sf(aes(fill = DRIVERS_LICENCE), color = "white") +
labs(title = "Ratio of persons with a driver's licence by Ward, Toronto 2016")
ggplot(TTS2016_wards) +
geom_sf(aes(fill = TTC_PASS), color = "white") +
labs(title = "Ratio of persons with a TTC metro pass by Ward, Toronto 2016")
ggplot(TTS2016_wards) +
geom_sf(aes(fill = WALKS_PER_DAY), color = "white") +
labs(title = "Average daily trips by walking per residents by Ward, Toronto 2016")
ggplot(TTS2016_wards) +
geom_sf(aes(fill = BIKES_PER_DAY), color = "white") +
labs(title = "Average daily trips by bicycle per residents by Ward, Toronto 2016")
Wellbeing Toronto - Transportation
WB-Transportation.xlsx
nbds <- st_read("C:/Users/14165/Desktop/Shapefiles/neighbourhoods_planning_areas_wgs84/NEIGHBORHOODS_WGS84.shp", stringsAsFactors=FALSE)
Reading layer `NEIGHBORHOODS_WGS84' from data source `C:\Users\14165\Desktop\Shapefiles\neighbourhoods_planning_areas_wgs84\NEIGHBORHOODS_WGS84.shp' using driver `ESRI Shapefile'
Simple feature collection with 140 features and 2 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: -79.63926 ymin: 43.581 xmax: -79.11524 ymax: 43.85546
epsg (SRID): 4326
proj4string: +proj=longlat +ellps=WGS84 +no_defs
nbds$AREA_S_CD <- as.integer(nbds$AREA_S_CD)
WB <- read.csv("WB-Transportation.csv")
str(WB)
'data.frame': 140 obs. of 6 variables:
$ AREA_S_CD : int 1 2 3 4 5 6 7 8 9 10 ...
$ TTC_Stops : int 338 70 45 40 29 70 81 58 63 61 ...
$ Non_Traffic_Collisions: int 727 224 109 62 63 105 80 27 39 49 ...
$ Traffic_Collisions : int 778 154 69 96 70 74 179 54 150 78 ...
$ Road_Kilometres : num 165 33.9 27.9 25.2 17.1 ...
$ Daily_Road_Volume : num 5957 3514 3545 7621 4116 ...
WB_nbds <- left_join(nbds, WB, by = "AREA_S_CD")
str(WB_nbds)
Classes ‘sf’ and 'data.frame': 140 obs. of 8 variables:
$ AREA_S_CD : int 97 27 38 31 16 118 63 3 55 59 ...
$ AREA_NAME : chr "Yonge-St.Clair (97)" "York University Heights (27)" "Lansing-Westgate (38)" "Yorkdale-Glen Park (31)" ...
$ TTC_Stops : int 28 235 44 155 106 55 44 45 62 53 ...
$ Non_Traffic_Collisions: int 58 598 142 1007 155 260 131 109 256 67 ...
$ Traffic_Collisions : int 99 548 173 246 265 171 193 69 154 106 ...
$ Road_Kilometres : num 12.8 67.6 39.3 49.7 84.6 ...
$ Daily_Road_Volume : num 7116 5546 6920 4194 7115 ...
$ geometry :sfc_POLYGON of length 140; first list element: List of 1
..$ : num [1:93, 1:2] -79.4 -79.4 -79.4 -79.4 -79.4 ...
..- attr(*, "class")= chr "XY" "POLYGON" "sfg"
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA
..- attr(*, "names")= chr "AREA_S_CD" "AREA_NAME" "TTC_Stops" "Non_Traffic_Collisions" ...
ggplot(WB_nbds) +
geom_sf(aes(fill = Traffic_Collisions), color = "white") +
labs(title = "Traffic Collisions by Ward, Toronto 2011") +
scale_fill_viridis(option="magma", name="Collisions", direction=-1)
ggplot(WB_nbds) +
geom_sf(aes(fill = Non_Traffic_Collisions), color = "white") +
labs(title = "Vehicle Collisions with Pedestrians/Other by Ward, Toronto 2011") +
scale_fill_viridis(option="magma", name="Collisions", direction=-1)
ggplot(WB_nbds) +
geom_sf(aes(fill = Daily_Road_Volume), color = "white") +
labs(title = "Daily Road Volume by Ward, Toronto 2011") +
scale_fill_viridis(option="magma", name="Road Volume", direction=-1)