There is a ton of spatial data on the City of Toronto Open Data Portal. Spatial resources are retrieved the same way as all other resources, by using get_resource(), and may require the sf package.

We can look at bicycle parking in Toronto. The result is an sf object with WGS84 projection.

library(opendatatoronto)
library(dplyr)

bike_parking_racks <- search_packages("Bicycle Parking Racks") %>%
  list_package_resources() %>%
  filter(name == "bicycle-parking-racks-wgs84") %>%
  get_resource()
#> Reading layer `BICYCLE_PARKING_RACK_WGS84' from data source `/tmp/RtmpHpqrqQ/BICYCLE_PARKING_RACK_WGS84.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 178 features and 29 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -79.59575 ymin: 43.60368 xmax: -79.25724 ymax: 43.82304
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +ellps=WGS84 +no_defs

bike_parking_racks
#> Simple feature collection with 178 features and 29 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -79.59575 ymin: 43.60368 xmax: -79.25724 ymax: 43.82304
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +ellps=WGS84 +no_defs
#> # A tibble: 178 x 30
#>    ADD_PT_ID ADD_NUM LN_NAM_FUL ADD_FULL POSTAL_CD MUN   CITY  CNTL_ID LO_NUM
#>        <dbl> <fct>   <fct>      <fct>    <fct>     <fct> <fct>   <dbl>  <int>
#>  1  30072958 1190    Dundas St… 1190 Du… M4M 0C5   form… Toro…  7.58e6   1190
#>  2  30085026 60      Lisgar St  60 Lisg… <NA>      form… Toro…  1.40e7     60
#>  3  10154425 1       St Clair … 1 St Cl… M4T 2V7   form… Toro…  1.02e7      1
#>  4    856375 100     Queen St W 100 Que… M5H 2N1   form… Toro…  1.15e6    100
#>  5     51630 5       Bartonvil… 5 Barto… M6M 2B1   YORK  Toro…  2.01e7      5
#>  6    310564 150     Borough Dr 150 Bor… M1P 4N7   SCAR… Toro…  1.08e5    150
#>  7    367443 71      New Fores… 71 New … M1V 2Z6   SCAR… Toro…  2.01e7     71
#>  8    379258 95      River Gro… 95 Rive… M1W 3T8   SCAR… Toro…  2.01e7     95
#>  9    394585 24      Victoria … 24 Vict… M4E 3R9   SCAR… Toro…  1.13e5     24
#> 10    772775 315     Bloor St W 315 Blo… M5S 1A3   form… Toro…  1.14e6    315
#> # … with 168 more rows, and 21 more variables: LO_NUM_SUF <fct>, HI_NUM <int>,
#> #   HI_NUM_SUF <fct>, LN_NAM_ID <dbl>, WARD_NAME <fct>, X <dbl>, Y <dbl>,
#> #   LONGITUDE <dbl>, LATITUDE <dbl>, MI_PRINX <dbl>, OBJECTID <dbl>,
#> #   CAPACITY <dbl>, MULTIMODAL <fct>, SEASONAL <fct>, SHELTERED <fct>,
#> #   SURFACE <fct>, STATUS <fct>, LOCATION <fct>, NOTES <fct>, MAP_CLASS <fct>,
#> #   geometry <POINT [°]>

If we want to plot this data on a map of Toronto, data to map the different neighbourhoods of Toronto is also available from the portal!

Then, we can plot the bike racks along with a map of Toronto:

library(ggplot2)

ggplot() +
  geom_sf(data = neighbourhoods[["geometry"]]) +
  geom_sf(data = bike_parking_racks) +
  theme_minimal()