Spatial Bike Network Analysis in Auckland

Introduction

The Geocomputation with R book has a great example of transport analysis in Bristol.

I decided this is a chance to get to know Open Street Map (OSM) and its data better given the flurry of bike route construction.

This is a bicycle network analysis of Auckland using open source spatial and bike counter data for 2018. It is a data cleaning intensive analysis, so if you would just like to see the results, skip to the Data Visualisation section.

# Load packages
library(tidyverse)
library(sf)
library(osmdata) # Open street map (OSM) data retrieval package
library(stringi) # for name reprex
library(stplanr) # Geographic transport data package
library(tmap) # Interactive leaflet maps
#library(kable)
library(kableExtra) # table output formatting

Data

We will source data from OSM, Auckland Transport(AT) and data.govt.nz.

For consistency and ease of use, we will also transform data into sf objects for analysis and plotting.

OSM Data

Use the osmdata R package to get Auckland OSM data. We will also reference the OSM wiki for bicyles which indicates the relevant data to source :

  • key = ‘highway’,value= ‘cycleway’
  • key = ‘bicycle’
# Get Auckland region polygon
auckland_region <- getbb(place_name ="auckland city", format_out = "sf_polygon")
# Get the OSM auckland data and highways features, use the Overpass query  specifying the bounding box with function bbox, and return as sf using osmdata_sf
highways <- getbb(place_name='auckland,new zealand') %>% 
      # The opq function obtains data from the overpass API
      opq() %>% 
      # Specify the features to add using add_osm_feature. Each feature successively added will be logically AND as per vignette
      add_osm_feature(key = 'highway',value= 'cycleway') %>%
      osmdata_sf () %>%
      # Remove redundant items from the different components of an osmdata object to save memory
      unique_osmdata() 
# Get the OSM auckland data and bike lanes features, we can simplify the opq function to include the bbox call in the getbb function
bikes <- opq(bbox='auckland') %>% 
      # Specify the features to add using add_osm_feature. Each feature successively added will be logically with 'AND'
      add_osm_feature(key = 'bicycle') %>%
      osmdata_sf () %>% 
      # Remove redundant items from the different components of an osmdata object to save memory
      unique_osmdata() 

AT Dike Counter Data

Get the AT bike counter data using the readxl R package. Note there may be some potential limitations with counter data.

url <- "https://at.govt.nz/media/1979441/monthlyakldcyclecountdatanov2010-dec2018.csv"
bikes_monthly <-read_csv(url) 
## Parsed with column specification:
## cols(
##   .default = col_number(),
##   Month = col_character(),
##   `Archibald Park` = col_character(),
##   `Beach Rd` = col_character(),
##   `Canada St` = col_character(),
##   `Carlton Gore Rd` = col_character(),
##   `Curran St` = col_character(),
##   `Dominion Rd (near Balmoral Rd)` = col_character(),
##   `Dominion Rd (near View Rd)` = col_character(),
##   `East Coast Rd` = col_character(),
##   `Glen Innes (Te Ara ki Uta ki Tai)` = col_character(),
##   `Grafton Bridge` = col_character(),
##   `Grafton Gully` = col_character(),
##   `Grafton Rd` = col_character(),
##   `Gt Nth Rd (citybound only until May 2017)` = col_character(),
##   `G Sth Road` = col_character(),
##   Highbrook = col_character(),
##   `Hopetoun St` = col_character(),
##   `K Rd` = col_character(),
##   `Lagoon Dr` = col_character(),
##   `Lake Road` = col_character()
##   # ... with 1 more columns
## )
## See spec(...) for full column specifications.

Auckland Cycle Network Data

Load the Auckland Cycle Network (ACN) data from data.govt.nz using rgdal R package.

url2 <- "http://data-atgis.opendata.arcgis.com/datasets/75bbb3afce054ee9a2826fd89c18e4bf_0.geojson"
acn_lines <- rgdal::readOGR(url2,stringsAsFactors = FALSE) 
## OGR data source with driver: GeoJSON 
## Source: "http://data-atgis.opendata.arcgis.com/datasets/75bbb3afce054ee9a2826fd89c18e4bf_0.geojson", layer: "75bbb3afce054ee9a2826fd89c18e4bf_0"
## with 1312 features
## It has 12 fields

Data Summary

Let’s take a look at summaries of the datasets.

OSM Data

# Check the class and summary of the auckland polygon
auckland_region
## Simple feature collection with 1 feature and 0 fields
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: 173.8963 ymin: -37.36447 xmax: 175.9032 ymax: -35.69839
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs
##                         geometry
## 1 POLYGON ((173.8963 -36.5586...
# Check the class of the bikes data, this will be similar class to highways data
class(bikes)
## [1] "list"       "osmdata"    "osmdata_sf"
# Take a look at the bikes dataset summary
bikes
## Object of class 'osmdata' with:
##                  $bbox : -37.0134665,174.6055514,-36.6934665,174.9255514
##         $overpass_call : The call submitted to the overpass API
##             $timestamp : [ Mon 2 Apr 2019 17:49:23 ]
##            $osm_points : 'sf' Simple Features Collection with 165 points
##             $osm_lines : 'sf' Simple Features Collection with 1356 linestrings
##          $osm_polygons : 'sf' Simple Features Collection with 9 polygons
##        $osm_multilines : 'sf' Simple Features Collection with 7 multilinestrings
##     $osm_multipolygons : 'sf' Simple Features Collection with 0 multipolygons

The bikes OSM data has been retrieved as an list, osmdata, osmdata_sf object. However within the list there are osm_* objects that have been retrieved as sf, data.frame objects.

# Take a look at the polygons and lines data for each of bikes removing the columns with all NAs and names with NAs
bikes$osm_polygons %>% 
      filter(!is.na(name)) %>% 
      select_if(~!all(is.na(.))) %>% 
      glimpse()
## Observations: 2
## Variables: 13
## $ osm_id        <fct> 8096920, 306899273
## $ name          <fct> Aotea Square, Fernglen Garden Bush Walk
## $ access        <fct> NA, yes
## $ area          <fct> yes, NA
## $ bicycle       <fct> yes, no
## $ foot          <fct> NA, yes
## $ highway       <fct> pedestrian, track
## $ horse         <fct> no, NA
## $ lit           <fct> yes, NA
## $ motor_vehicle <fct> NA, no
## $ name.ja       <fct> アオテア・スクエア, NA
## $ surface       <fct> paved, NA
## $ geometry      <POLYGON [°]> POLYGON ((174.7631 -36.8517..., POLYGON...
bikes_lines <- bikes$osm_lines %>% 
      filter(!is.na(name)) %>% 
      select_if(~!all(is.na(.)))  
bikes_lines %>%  
      glimpse()
## Observations: 447
## Variables: 85
## $ osm_id                     <fct> 4279735, 4279736, 4282804, 4290919,...
## $ name                       <fct> Darby Street, Elliott Street, Alfre...
## $ FIXME                      <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ LINZ.layer                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ LINZ.source_version        <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ access                     <fct> NA, NA, NA, yes, no, NA, NA, NA, NA...
## $ alt_name                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ attribution                <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ bicycle                    <fct> yes, yes, yes, yes, yes, yes, yes, ...
## $ bridge                     <fct> NA, NA, NA, NA, NA, NA, NA, NA, via...
## $ bridge.movable             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ bus                        <fct> NA, NA, yes, NA, NA, NA, NA, NA, NA...
## $ bus.lanes                  <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ bus.lanes.backward         <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ bus.lanes.forward          <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ construction               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ contact.website            <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ covered                    <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ cycleway                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ cycleway.both              <fct> NA, NA, NA, no, NA, NA, NA, NA, NA,...
## $ cycleway.left              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ description                <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ designation                <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination                <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination.lanes          <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination.ref            <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination.ref.lanes      <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination.ref.to         <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination.ref.to.lanes   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ destination.street         <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ duration                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ ele                        <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ emergency_response_section <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ foot                       <fct> yes, yes, yes, yes, yes, yes, NA, N...
## $ goods.conditional          <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ hgv.conditional            <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ highway                    <fct> living_street, living_street, uncla...
## $ horse                      <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ junction.ref               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ lanes                      <fct> NA, NA, 1, NA, 1, NA, NA, 1, 2, 1, ...
## $ lanes.backward             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ lanes.forward              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ layer                      <fct> NA, NA, NA, NA, NA, NA, NA, NA, 1, ...
## $ lit                        <fct> NA, NA, NA, yes, NA, NA, NA, NA, NA...
## $ man_made                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ maxspeed                   <fct> 10, 10, 10, 50, NA, NA, 50, 50, 80,...
## $ maxspeed.type              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ maxspeed.variable          <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ mooring                    <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ motor_vehicle              <fct> NA, NA, no, yes, NA, yes, NA, NA, N...
## $ motorcar                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ motorcar.conditional       <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ motorcycle                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ name.ja                    <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ note                       <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ oneway                     <fct> yes, yes, yes, NA, yes, NA, no, yes...
## $ proposed                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ psv                        <fct> NA, NA, yes, NA, yes, NA, NA, NA, N...
## $ railway                    <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ ref                        <fct> NA, NA, NA, NA, NA, NA, NA, NA, 10,...
## $ route                      <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ sac_scale                  <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ segregated                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ service                    <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ sidewalk                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ source                     <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ source.geometry            <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ source.maxspeed            <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ source.oneway              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ source_ref                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ start_date                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ surface                    <fct> asphalt, asphalt, NA, paved, NA, NA...
## $ tracktype                  <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ trail_visibility           <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ tunnel                     <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ turn.lanes                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ turn.lanes.backward        <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ turn.lanes.forward         <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ type                       <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ vehicle                    <fct> NA, NA, no, NA, NA, NA, NA, NA, NA,...
## $ visibility                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ width                      <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ wikidata                   <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ wikipedia                  <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA,...
## $ geometry                   <LINESTRING [°]> LINESTRING (174.765 -36...
# Tabulate the highway variable for more information on the categories
table(bikes_lines$highway)
## 
##     bridleway  construction      cycleway       footway living_street 
##             0             1             5            40            10 
##      motorway motorway_link          path    pedestrian       primary 
##            32             1            60             3           110 
##      proposed   residential     secondary       service         steps 
##             1            13            88             2             0 
##      tertiary         track         trunk    trunk_link  unclassified 
##             6            22            36             0            14

It looks like the bikes$osm_polygons data relate to pedestrian and track data, and the rest of the polygons are not named. We will ignore the bikes$osm_polygons data and use the bikes$osm_lines data.

# Take a look at the highways dataset summary
highways
## Object of class 'osmdata' with:
##                  $bbox : -37.0134665,174.6055514,-36.6934665,174.9255514
##         $overpass_call : The call submitted to the overpass API
##             $timestamp : [ Mon 2 Apr 2019 17:49:16 ]
##            $osm_points : 'sf' Simple Features Collection with 0 points
##             $osm_lines : 'sf' Simple Features Collection with 651 linestrings
##          $osm_polygons : 'sf' Simple Features Collection with 12 polygons
##        $osm_multilines : 'sf' Simple Features Collection with 0 multilinestrings
##     $osm_multipolygons : 'sf' Simple Features Collection with 0 multipolygons

The OSM highways data has been retrieved as an list, osmdata, osmdata_sf object. However within the list there are osm_* objects that have been retrieved as sf, data.frame objects.

highways_lines <- highways$osm_lines %>% 
      filter(!is.na(name)) %>% 
      select_if(~!all(is.na(.))) 
highways_lines %>%       
      glimpse()
## Observations: 183
## Variables: 35
## $ osm_id               <fct> 12249855, 12250191, 23215852, 23215865, 2...
## $ name                 <fct> Waikaraka Cycleway, Waikaraka Cycleway, N...
## $ LINZ.source_version  <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ access               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ attribution          <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ bicycle              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ bridge               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ colour               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ construction         <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ construction.highway <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ created_by           <fct> NA, NA, NA, NA, Tways 0.2, NA, NA, NA, NA...
## $ cycleway             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ foot                 <fct> yes, yes, yes, yes, NA, NA, yes, yes, yes...
## $ highway              <fct> cycleway, cycleway, cycleway, cycleway, c...
## $ horse                <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ layer                <fct> 1, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ lit                  <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ man_made             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ motor_vehicle        <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ name.en              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ name.mi              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ note                 <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ oneway               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ oneway.bicycle       <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ proposed             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ smoothness           <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ source               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ source_2             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ source_ref           <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ surface              <fct> NA, NA, concrete, concrete, NA, NA, NA, N...
## $ tunnel               <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ website              <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ wikidata             <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ wikipedia            <fct> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ geometry             <LINESTRING [°]> LINESTRING (174.8262 -36.92.....
highways$osm_polygons %>% 
      filter(!is.na(name)) %>% 
      select_if(~!all(is.na(.))) %>% 
      glimpse()
## Observations: 2
## Variables: 7
## $ osm_id   <fct> 304326461, 304337319
## $ name     <fct> Sanders reserve Kids loop, Sanders Reserve recreation...
## $ foot     <fct> no, no
## $ highway  <fct> cycleway, cycleway
## $ horse    <fct> no, no
## $ oneway   <fct> yes, yes
## $ geometry <POLYGON [°]> POLYGON ((174.6375 -36.7671..., POLYGON ((17...

It looks like the highways$osm_polygons data may relate to MTB loops such as Sander’s Reserve, and the rest of the polygons are not named. We will ignore the highways$osm_polygons data and use the highways$osm_lines data.

AT Bike Counter Data

Let’s take a look at a summary of the bikes counter data.

# Take a look at the monthly bikes counter data
glimpse(bikes_monthly)
## Observations: 99
## Variables: 46
## $ Month                                       <chr> "(Te Atatu)\"", "N...
## $ `Archibald Park`                            <chr> "Oceanview Rd, Wai...
## $ `Beach Rd`                                  <chr> "Orewa", NA, NA, N...
## $ `Canada St`                                 <chr> "Ormiston Rd Flat ...
## $ `Carlton Gore Rd`                           <chr> "Pukekohe Queen St...
## $ `Curran St`                                 <chr> "Quay St Spark Are...
## $ `Dominion Rd (near Balmoral Rd)`            <chr> "Quay St totem", N...
## $ `Dominion Rd (near View Rd)`                <chr> "Rankin Ave, New L...
## $ `East Coast Rd`                             <chr> "St Luke's Rd", NA...
## $ `Glen Innes (Te Ara ki Uta ki Tai)`         <chr> "SH20A (sth of Kir...
## $ `Grafton Bridge`                            <chr> "SW shared path", ...
## $ `Grafton Gully`                             <chr> "Symonds St", NA, ...
## $ `Grafton Rd`                                <chr> "Tamaki Dr (EB + W...
## $ `Gt Nth Rd (citybound only until May 2017)` <chr> "Te Atatu Peninsul...
## $ `G Sth Road`                                <chr> "Te Wero Bridge", ...
## $ Highbrook                                   <chr> "Twin Streams", "1...
## $ `Hopetoun St`                               <chr> "Upper Harbour", N...
## $ `K Rd`                                      <chr> "Upper Queen St", ...
## $ `Lagoon Dr`                                 <chr> "Victoria St West"...
## $ `Lake Road`                                 <chr> "Waterview SP (Uni...
## $ `Mangere Bridge`                            <dbl> NA, NA, NA, NA, NA...
## $ `Mangere Safe Routes`                       <dbl> NA, NA, NA, NA, NA...
## $ `Matakana Bridge`                           <dbl> NA, NA, NA, NA, NA...
## $ `Nelson St cycleway`                        <dbl> NA, NA, NA, NA, NA...
## $ `Nelson St Lightpath`                       <dbl> NA, NA, NA, NA, NA...
## $ `NW Cycleway (Kingsland)`                   <dbl> NA, 8894, 6575, 78...
## $ `NW Cycleway \n(Te Atatu)`                  <dbl> NA, 12760, 9964, 1...
## $ `Oceanview Rd, Waiheke`                     <dbl> NA, NA, NA, NA, NA...
## $ Orewa                                       <dbl> NA, 3305, 2564, 45...
## $ `Ormiston Rd Flat Bush`                     <dbl> NA, NA, NA, NA, NA...
## $ `Pukekohe Queen St`                         <int> NA, NA, NA, NA, NA...
## $ `Quay St Spark Arena`                       <dbl> NA, NA, NA, NA, NA...
## $ `Quay St totem`                             <dbl> NA, NA, NA, NA, NA...
## $ `Rankin Ave, New Lynn`                      <dbl> NA, NA, NA, NA, NA...
## $ `St Luke's Rd`                              <dbl> NA, NA, NA, NA, NA...
## $ `SH20A (sth of Kirkbride)`                  <dbl> NA, NA, NA, NA, NA...
## $ `SW shared path`                            <dbl> NA, NA, NA, NA, NA...
## $ `Symonds St`                                <dbl> NA, NA, NA, NA, NA...
## $ `Tamaki Dr (EB + WB)`                       <dbl> NA, NA, NA, NA, NA...
## $ `Te Atatu Peninsula`                        <dbl> NA, NA, NA, NA, NA...
## $ `Te Wero Bridge`                            <dbl> NA, NA, NA, NA, NA...
## $ `Twin Streams`                              <dbl> NA, 3025, 2796, 45...
## $ `Upper Harbour`                             <dbl> NA, 3648, 2487, 40...
## $ `Upper Queen St`                            <dbl> NA, NA, NA, NA, NA...
## $ `Victoria St West`                          <dbl> NA, NA, NA, NA, NA...
## $ `Waterview SP (Unitec)`                     <dbl> NA, NA, NA, NA, NA...

Auckland Cycle Network Data

Finally take a look at the acn_lines bikes network.

acn_lines[1,1]
## class       : SpatialLinesDataFrame 
## features    : 1 
## extent      : 174.6714, 174.677, -36.59282, -36.59208  (xmin, xmax, ymin, ymax)
## coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
## variables   : 1
## names       : OBJECTID 
## value       :     1001

Exploratory Data Analysis

Since the data are sf objects, we can use ggplot2 to create quick initial EDA plots.

OSM data

Let’s first take a look at the OSM data using ggplot2, plotting the bike_lines and highways_lines in darkorange.

# Creat a ggplot map of the bike_lines dataset
ggplot()+
      geom_sf(data=bikes_lines,colour="darkorange")+
      geom_sf(data=auckland_region,fill=NA)

It appears that there may be ferry routes included in the data. We will remove these in the cleaning steps.

# Creat a ggplot map of the highways_lines dataset
ggplot()+
      geom_sf(data=highways_lines,colour="darkorange")+
      geom_sf(data=auckland_region,fill=NA)

Auckland Cycle Network Data

Now plot the acn_lines in purple.

# Creat a ggplot map of the acn_lines dataset, converting the SpatialDataFrame to an sf object 
acn_lines_sf<- acn_lines  %>% 
      st_as_sf() 
ggplot()+
      geom_sf(data=acn_lines_sf,colour="purple")+
      geom_sf(data=auckland_region,fill=NA)

The acn_lines data looks to cover the broader Auckland region, we may need to filter to get the routes close to the city.

Now use the stplanr R package to create spatial networks. We will use the acn_lines object as this is imported with class SpatialLinesDataFrame. Then visualise network centrality and plot the edge betweenness.

# Creat a composite object with slots, where the s argument is a SpatialLinesDataFrame
acn_lines_sln <- SpatialLinesNetwork(acn_lines)
# Take a look at the class of the new object
class(acn_lines_sln)
## [1] "SpatialLinesNetwork"
## attr(,"package")
## [1] "stplanr"
# Take a look at the slot names
slotNames(acn_lines_sln)
## [1] "sl"          "g"           "nb"          "weightfield"
# Take a look at the class of the graph component, g
class(acn_lines_sln@g)
## [1] "igraph"

The SpatialLinesNetwork function creates a SpatialLinesNetwork object creates sl, g, nb, weightfield components. We can plot the g (graph) and sl (spatial) components.

e <- igraph::edge_betweenness(acn_lines_sln@g)
# Plot the igraph  from the sl component and the edge from the g component
plot(acn_lines_sln@sl,
     lwd = e / 10,
     col = "purple")

This is a very brief look at potential nodes in the network.

Data Cleaning

OSM Data

First we will transform the CRS of the datasets for spatial mapping.

# Get nz data set with CRS set
nz <- spData::nz
# Transform the osm data to the nz CRS for plotting
bikes_wgs84 <- st_transform(bikes_lines, st_crs(nz)) 
# Transform the osm line data to the nz CRS for plotting
highways_lines_wgs84 <- st_transform(highways_lines , st_crs(nz))
highways_lines_wgs84$name <- as.character(highways_lines_wgs84$name)
# Correct spelling of  Grafton Gully Cycleway in the OSM file. This change has also been proposed in OSM - changeset #: 68819107
highways_lines_wgs84$name <- highways_lines_wgs84$name %>% 
      str_replace_all( pattern = "Grafton Gully cycleway", replacement = "Grafton Gully Cycleway")

Now we will get the bbox of the highways_lines_wgs84 data and use this bbox for the maps.

# Use st_bbox to get bbox coordinates
bbox_plots <- st_bbox(highways_lines_wgs84)

Next remove the ferry routes.

bikes_wgs84 <- bikes_wgs84 %>% 
      filter(route!="ferry")

AT Bike Counter Data

We will tidy the bike counter data with the tidyr R package so that we can join it to the OSM and acn_lines_sf data. We will use the stringr and stringi R packages for regex.

# Remove the first row of the dataset
bikes_monthly <- bikes_monthly %>% 
      slice(-1)
# Convert the character date variable to a date variable using lubridate
bikes_monthly$Month <- lubridate::dmy(paste0("01-",bikes_monthly$Month))
# Add a year variable
bikes_monthly <- bikes_monthly %>% 
      mutate(Year=lubridate::year(Month))
# Create a tidy dataframe filtered for complete 2018 data
bikes_2018 <- bikes_monthly %>% 
      filter(Year==2018) %>% 
      select_if(~!any(is.na(.))) %>% 
      gather(key = "Street",value="counts",2:41) %>% 
      # Add Cycleway to the name which will be used to join with the osm data
      mutate(name=paste0(Street," Cycleway"))  
# Update the names in the counter sum file to match with some names in the osm data
bikes_2018$name <- bikes_2018$name %>% 
      str_replace_all( c( "Rd "= "Road ", 
                          "Nelson St Lightpath Cycleway" = "Te Ara I Whiti (The Lightpath)",
                          "Quay St Spark Arena Cycleway" = "Quay Street Cycleway",
                          "Quay St totem Cycleway"= "Quay Street Cycleway",
                          "Grafton Bridge Cycleway" = "Grafton Bridge",
                          "Nelson St cycleway Cycleway" = "Nelson Street Cycleway",
                          "Te Wero Bridge Cycleway" = "Te Wero Bridge",
                          "Lake Road Cycleway" = "Lake Road"))   %>% 
      # For replacements with brackets we need to use stringi
      stringi::stri_replace_all_fixed( pattern = "Tamaki Dr (EB + WB) Cycleway", replacement = "Tamaki Drive Cycleway") %>% 
      stringi::stri_replace_all_fixed( pattern = "Dominion Road (near View Road) Cycleway", replacement =  "Dominion Road West Safe Cycle Route")%>% 
      stringi::stri_replace_all_fixed( pattern = "NW Cycleway (Kingsland) Cycleway", replacement = "Northwestern Cycleway") %>% 
      stringi::stri_replace_all_fixed( pattern = "NW Cycleway \n(Te Atatu) Cycleway", replacement = "Northwestern Cycleway")  

# Convert the remove the comma from the character and counts to numeric using stringr str_replace
bikes_2018$counts <- as.numeric(stringr::str_replace_all(bikes_2018$counts, pattern= ",", replacement = ""))

Now let’s view the 2018 bike counter monthly data as a facet plot by street name to visualise trends and which routes may be the busier routes.

# Take a look at the monthly bike counter line plots
# bikes_2018$Month <- stri_wrap(bikes_2018$Month,n=13) # tried to wrap titles but it doesn't currently work
ggplot(bikes_2018,aes(Month,counts)) +
      geom_line()+
      facet_wrap(~Street)+
      theme(axis.title.x=element_blank(),
        axis.text.x=element_blank(),
        axis.ticks.x=element_blank())

The popular routes have seasonality with numbers dipping in the winter months. The less popular routes have flat, low numbers.

# Total the counts by street for 2018
bikes_2018_sum <- bikes_2018 %>% 
      group_by(name) %>% 
      summarise(Total =sum(counts)) 
# View the top 20 busiest routes in 2018 according to the bike counter data
bikes_2018_sum %>% 
      arrange(desc(Total)) %>% 
      head(20) %>% 
      knitr::kable(format = "markdown")
name Total
Quay Street Cycleway 738166
Northwestern Cycleway 558061
Tamaki Drive Cycleway 454885
Te Wero Bridge 254055
Grafton Bridge 198657
K Road Cycleway 177635
Te Ara I Whiti (The Lightpath) 172441
Nelson Street Cycleway 171848
Grafton Gully Cycleway 137844
Mangere Bridge Cycleway 134360
Symonds St Cycleway 132282
Lake Road 125154
Beach Road Cycleway 115011
Dominion Road (near View Rd) Cycleway 112206
Curran St Cycleway 105325
Orewa Cycleway 96110
Gt Nth Road (citybound only until May 2017) Cycleway 89095
Carlton Gore Road Cycleway 82532
Waterview SP (Unitec) Cycleway 73606
St Luke’s Road Cycleway 68954

Auckland Cycle Network Data

# Transform the osm line data to the nz CRS for plotting
acn_lines_wgs84 <- st_transform(acn_lines_sf %>% 
      filter(!is.na(ROADNAME)) , st_crs(nz))
# Update the names in the acn data file to match with some names in the osm data https://stringr.tidyverse.org/articles/regular-expressions.html
acn_lines_wgs84$ROADNAME <- acn_lines_wgs84$ROADNAME  %>% 
      str_replace_all(c("St$" = "Street",
                        "Street$" = "Street Cycleway",
                        "Dr$" = "Drive", 
                        "dr$" = "Drive",
                        "Drive$" = "Drive Cycleway",
                        "Rd$" = "Road",
                        "Road$" = "Road Cycleway",
                        "Grafton Bridge Cycleway" = "Grafton Bridge",
                        
                        "Jellico St-Bauemont Street Cycleway"="Te Wero Bridge",
                        "Lake Road Cycleway"="Lake Road",
                        "SH20 Mangere Motorway Bridge" = "Mangere Bridge Cycleway")) %>% 
      stringi::stri_replace_all_fixed( pattern="Northwestern Cycleway (Great North to Lincoln)", replacement =  "Northwestern Cycleway") %>% 

      stringi::stri_replace_all_fixed( pattern="Northwestern Cycleway (Newton Rd to Great North Road)",replacement  = "Northwestern Cycleway") %>% 
      
      stringi::stri_replace_all_fixed( pattern="Dominion Road Cycleway Cycleway",replacement  = "Dominion Road (near View Rd) Cycleway")  %>% 
      
      stringi::stri_replace_all_fixed( pattern="The Lightpath",replacement  = "Te Ara I Whiti (The Lightpath)") %>% 
      
      stringi::stri_replace_all_fixed( pattern="Harbour Edge (Quay St)",replacement  = "Quay Street Cycleway") 
# Remove large datasets to save memory
rm(bikes)
rm(highways)
rm(acn_lines)
rm(acn_lines_sf)

Combine Data

Now combine the total counts with the osm and the acn_lines datasets.

# Join the total sums to the osm highways lines data
highways_lines_wgs84_sum <- left_join(highways_lines_wgs84,bikes_2018_sum, by="name")
# Join the total sums to the osm highways lines data
bikes_wgs84_sum <- left_join(bikes_wgs84,bikes_2018_sum, by="name")
# Join the total sums to the osm acn lines data
acn_lines_wgs84_sum <- left_join(acn_lines_wgs84,bikes_2018_sum, by=c("ROADNAME"="name"))
# Row bind the dataframe components
bikenet_wgs84 <- bind_rows(data.frame(highways_lines_wgs84_sum %>% select(name,osm_id,Total)),
                 data.frame(bikes_wgs84_sum %>% select(name,osm_id,Total)))
# Row bind the geometry components
bikenet_wgs84$geometry <- c(highways_lines_wgs84_sum$geometry,bikes_wgs84_sum$geometry)
# Convert back to sf
bikenet_wgs84 <- bikenet_wgs84 %>% 
      st_as_sf()
# Let's check which of the top 20 we have covered in our osm network
bikes_2018_sum %>%
       mutate('In counter?'="yes") %>% 
       arrange(desc(Total)) %>% 
       head(20) %>% 
            full_join(bikenet_wgs84 %>%
                            select(name) %>% 
                            mutate('In network?'="yes") %>%
                            st_set_geometry(NULL)
                   , by = "name")  %>% 
      unique() %>% 
      knitr::kable() %>%
      kable_styling() %>%
      scroll_box(width = "800px", height = "200px")
name Total In counter? In network?
Quay Street Cycleway 738166 yes yes
Northwestern Cycleway 558061 yes yes
Tamaki Drive Cycleway 454885 yes yes
Te Wero Bridge 254055 yes NA
Grafton Bridge 198657 yes NA
K Road Cycleway 177635 yes NA
Te Ara I Whiti (The Lightpath) 172441 yes yes
Nelson Street Cycleway 171848 yes yes
Grafton Gully Cycleway 137844 yes yes
Mangere Bridge Cycleway 134360 yes NA
Symonds St Cycleway 132282 yes NA
Lake Road 125154 yes NA
Beach Road Cycleway 115011 yes yes
Dominion Road (near View Rd) Cycleway 112206 yes NA
Curran St Cycleway 105325 yes NA
Orewa Cycleway 96110 yes NA
Gt Nth Road (citybound only until May 2017) Cycleway 89095 yes NA
Carlton Gore Road Cycleway 82532 yes yes
Waterview SP (Unitec) Cycleway 73606 yes NA
St Luke’s Road Cycleway 68954 yes NA
Waikaraka Cycleway NA NA yes
Abbotsford Way NA NA yes
Takapuna Cycle Route NA NA yes
Onepoto Cycleway NA NA yes
Coronation Road NA NA yes
Southern Isthmus Cycleway NA NA yes
Henderson Creek shared path NA NA yes
International Walkway of Trees NA NA yes
North West Route NA NA yes
Oratia Stream Shared Path NA NA yes
Arch Hill Mountain Bike Trails NA NA yes
Upper Waikumete Walk and Cycleway NA NA yes
Te Whau Pathway NA NA yes
Rosedale to Unsworth heights NA NA yes
Rosedale to Unsworth hieghts NA NA yes
Ian McKinnon Drive Cycleway NA NA yes
Westhaven Promenade NA NA yes
Sanders Reserve kowhai loop NA NA yes
Recreational loop short cut NA NA yes
Eric Armishaw Reserve Walkway NA NA yes
Eric Armishaw Boardwalk NA NA yes
Pitt Street Cycleway NA NA yes
Britomart Place Cycleway NA NA yes
Dominion Road East Safe Cycle Route NA NA yes
Dominion Road West Safe Cycle Route NA NA yes
Te Ara Ki Uta Ki Tai NA NA yes
Grey Lynn Greenway NA NA yes
Mt Roskill Safe Routes NA NA yes
Avondale Kids Bike Park NA NA yes
Mokomoko Bridge NA NA yes
Onepoto Domain Kids Bike Park NA NA yes
Richmond Road Cycleway NA NA yes
Te Ara I Whiti NA NA yes
Moire Park Pump Track NA NA yes
Curry’s Lane Cycle Route NA NA yes
Rainbow Path NA NA yes
Federal Street Cycleway NA NA yes
Tirohanga Whanui NA NA yes

If we check OpenStreetMap we can see that the Te Wero Bridge, K Road, Curran St, Mangere Bridge, Lake Road and Symonds Street Cycleways (and other less popular routes) are not currently labelled in osm data.

# Let's check which of the top 20 we have covered in our osm network
bikes_2018_sum %>%
       mutate('In counter?'="yes") %>% 
       arrange(desc(Total)) %>% 
       head(20) %>% 
            full_join(acn_lines_wgs84_sum  %>% 
                            select(ROADNAME,LOCALBOARD,STATUS) %>% 
                            mutate('In acn network?'="yes") %>%
                            st_set_geometry(NULL), 
                      by = c("name"="ROADNAME"))  %>% 
      unique() %>% 
      knitr::kable() %>%
      kable_styling() %>%
      scroll_box(width = "800px", height = "200px")
name Total In counter? LOCALBOARD STATUS In acn network?
Quay Street Cycleway 738166 yes Waitemata Existing yes
Northwestern Cycleway 558061 yes Albert - Eden Existing yes
Northwestern Cycleway 558061 yes Whau Existing yes
Northwestern Cycleway 558061 yes Henderson - Massey Existing yes
Northwestern Cycleway 558061 yes Waitemata Existing yes
Tamaki Drive Cycleway 454885 yes NA Existing yes
Tamaki Drive Cycleway 454885 yes Orakei Existing yes
Te Wero Bridge 254055 yes Waitemata Existing yes
Grafton Bridge 198657 yes NA NA NA
K Road Cycleway 177635 yes NA NA NA
Te Ara I Whiti (The Lightpath) 172441 yes Waitemata Existing yes
Nelson Street Cycleway 171848 yes Waitemata Existing yes
Grafton Gully Cycleway 137844 yes Waitemata Existing yes
Mangere Bridge Cycleway 134360 yes Mangere – Otahuhu Existing yes
Symonds St Cycleway 132282 yes NA NA NA
Lake Road 125154 yes Devonport - Takapuna Existing yes
Beach Road Cycleway 115011 yes Waitemata Existing yes
Dominion Road (near View Rd) Cycleway 112206 yes NA NA NA
Curran St Cycleway 105325 yes NA NA NA
Orewa Cycleway 96110 yes NA NA NA
Gt Nth Road (citybound only until May 2017) Cycleway 89095 yes NA NA NA
Carlton Gore Road Cycleway 82532 yes Waitemata Existing yes
Carlton Gore Road Cycleway 82532 yes NA Existing yes
Waterview SP (Unitec) Cycleway 73606 yes NA NA NA
St Luke’s Road Cycleway 68954 yes NA Existing yes
St Luke’s Road Cycleway 68954 yes Albert - Eden Existing yes
Buckland Road Cycleway NA NA Mangere - Otahuhu Existing yes
cycleway NA NA Mangere - Otahuhu Existing yes
Station Road (Papatoetoe) NA NA Otara - Papatoetoe Existing yes
Salisbury Reserve NA NA Waitemata Existing yes
St Georges Street Cycleway NA NA Otara - Papatoetoe Existing yes
Kirkbride Road/Massey Road Cycleway NA NA Mangere - Otahuhu Existing yes
Off road cycle route NA NA Mangere - Otahuhu Existing yes
Puhinui Road Cycleway NA NA Otara - Papatoetoe Existing yes
Lambie Drive Cycleway NA NA Otara - Papatoetoe Existing yes
Puhinui Road Cycleway NA NA NA Existing yes
Great South Road Cycleway NA NA Otara - Papatoetoe Existing yes
Great South Road Cycleway NA NA Mangere - Otahuhu Existing yes
Great South Road (East Tamaki Rd) NA NA Otara - Papatoetoe Existing yes
Great South Road Cycleway NA NA NA Existing yes
Great South Road Cycleway NA NA Manurewa Existing yes
Sunnynook Park NA NA Devonport-Takapuna Existing yes
Queen Street Cycleway NA NA Franklin Existing yes
Porchester Road (Papakura end) NA NA Papakura Existing yes
Kauri Heart Avenue NA NA Papakura Existing yes
Hingaia Rd (Over SH1) NA NA Papakura Existing yes
cycleway NA NA Papakura Existing yes
Great South Road Cycleway NA NA Papakura Existing yes
Off road cycle route NA NA Manurewa Existing yes
Eastern Rail Cycleway (Ellerslie-Panmure Hwy to Triangle Road) NA NA Maungakiekie - Tamaki Existing yes
Great South Road (Takanini) NA NA Papakura Existing yes
Eastern Rail Cycleway (Ellerslie-Panmure Hwy to Morrin Road) NA NA Maungakiekie - Tamaki Existing yes
Mt Wellington Highway (Waipuna) NA NA Maungakiekie - Tamaki Existing yes
Weymouth Road Cycleway NA NA NA Existing yes
Weymouth Road Cycleway NA NA Manurewa Existing yes
Weymputh Road Cycleway NA NA NA Existing yes
Puhinui Rd (Noel Burnside) NA NA Otara - Papatoetoe Existing yes
Te Irirangi Drive Cycleway NA NA Howick Existing yes
Ormiston Road Cycleway NA NA Howick Existing yes
Dominion Road alternative NA NA Puketapapa Existing yes
Fort Street Cycleway NA NA Waitemata Existing yes
Chapel Road Cycleway NA NA Howick Existing yes
Flat Bush Cycle Route NA NA Howick Existing yes
Second View Ave - Maraetai Drive Cycleway NA NA Franklin Existing yes
Whitford-Maraetai Road Cycleway NA NA Franklin Existing yes
Smales Road Cycleway NA NA NA Existing yes
Crawford Ave NA NA Mangere - Otahuhu Existing yes
McManus Pl to Highbrook Dr Off Road Cycleway NA NA Mangere - Otahuhu Existing yes
Lloyd Elsmore Park to Botany NA NA Howick Existing yes
Great North Road Cycleway NA NA NA Existing yes
Morrin Road Cycleway NA NA Maungakiekie - Tamaki Existing yes
Future Road (Westgate) NA NA Henderson Massey Existing yes
Birman Close NA NA Howick Existing yes
Matakana to Omaha Cycle trail NA NA Rodney Existing yes
Onewa Road Cycleway NA NA Kaipatiki Existing yes
Clydeside Ave NA NA Howick Existing yes
Dora Street Cycleway NA NA Henderson Massey Existing yes
Gosford Drive Cycleway NA NA Howick Existing yes
Off road cycle route NA NA Howick Existing yes
Queen Street (Northcote) NA NA Kaipatiki Existing yes
Coubray Place NA NA Howick Existing yes
Connifer Grove cycle route NA NA Papakura Existing yes
Oruarangi Road Cycleway NA NA Mangere - Otahuhu Existing yes
Glenfield Road Cycleway NA NA Kaipatiki Existing yes
Glenfield Road Cycleway NA NA NA Existing yes
Glenfield Road (Sunset Rd) NA NA Kaipatiki Existing yes
Kaipataki Road Cycleway NA NA NA Existing yes
Rosedale Park North NA NA Upper Harbour Existing yes
Unsworth Park NA NA Upper Harbour Existing yes
Barbados Drive Cycleway NA NA Upper Harbour Existing yes
George Bolt Memorial Drive Cycleway NA NA Mangere - Otahuhu Existing yes
Brigham Creek Road Cycleway NA NA Upper Harbour Existing yes
Eastern Waterfront City Connection NA NA Waitemata Existing yes
Orakei Road Cycleway NA NA Orakei Existing yes
Point England Road Cycleway NA NA NA Existing yes
Tripoli Road Cycleway NA NA NA Existing yes
Erima Road Cycleway NA NA NA Existing yes
Pilkington Road Cycleway NA NA NA Existing yes
Hilsborough Road Cycleway NA NA Puketapapa Existing yes
Donald Bruce Road Cycleway NA NA Waiheke Existing yes
Causeway Road Cycleway NA NA Waiheke Existing yes
Onetangi Road Cycleway NA NA Waiheke Existing yes
Merton Road Cycleway NA NA Orakei Existing yes
Hibiscus Coast Hwy (Silverdale to Orewa) NA NA Hibiscus and Bays Existing yes
Newton Road Cycleway NA NA Waitemata Existing yes
Queen Street Cycleway NA NA Kaipataki Existing yes
Oteha Valley Road Cycleway NA NA Upper Harbour Existing yes
Spencer Road Cycleway NA NA Upper Harbour Existing yes
New Existing unbuffered cycle lane - Steve NA NA Upper Harbour Existing yes
Harbourside Drive Cycleway NA NA Papakura Existing yes
Coronation Road to Mahunga Drive Cycleway NA NA Mangere – Otahuhu Existing yes
Mahunga Drive Cycleway NA NA Mangere – Otahuhu Existing yes
Kuhanui Drive Cycleway NA NA Papakura Existing yes
Kaimanawa Road Cycleway NA NA Papakura Existing yes
Lake Drive Cycleway NA NA Papakura Existing yes
Hinau Road Cycleway NA NA Papakura Existing yes
Anchorage Reserve NA NA Papakura Existing yes
Anchorage Drive Link NA NA Papakura Existing yes
Harbourside Drive Shared Path Ext. NA NA Papakura Existing yes
Bay connection NA NA Howick Existing yes
Henderson Creek Path NA NA Henderson - Massey Existing yes
Oratia Path NA NA Waitakere Ranges Existing yes
Lower Opanuku Cycleway NA NA Waitakere Ranges Existing yes
Lower Opanuku Cycleway NA NA Henderson - Massey Existing yes
Pakuranga Farm Cove NA NA Howick Existing yes
War Memorial Park NA NA Puketapapa Existing yes
Keith Hay Park NA NA Puketapapa Existing yes
Memorial and Somerset Road Cycleway NA NA Puketapapa Existing yes
Kiwi Esplanade NA NA Mangere - Otahuhu Existing yes
Maioro Street Cycleway NA NA Whau Existing yes
Maioro Street Cycleway NA NA Puketapapa Existing yes
Te Atatu Road Cycleway NA NA Henderson - Massey Existing yes
Forrest Hill Road Cycleway NA NA Devonport - Takapuna Existing yes
East Coast Road Cycleway NA NA Devonport - Takapuna Existing yes
Upper Harbour Drive (Greenhithe to SH18) NA NA Upper Harbour Existing yes
Albany Highway (North) NA NA Upper Harbour Existing yes
Shakespeare Road Cycleway NA NA Devonport-Takapuna Existing yes
Orewa River Shared Path NA NA Hibiscus and Bays Existing yes
Kelvin Hart Drive Cycleway NA NA Howick Existing yes
Waterview Shared path NA NA Albert - Eden Existing yes
Sutherland Road Cycleway NA NA Albert - Eden Existing yes
Coronation Road Cycleway NA NA Maungakiekie - Tamaki Existing yes
Waikaraka Cycleway NA NA Maungakiekie - Tamaki Existing yes
Hendry Ave (SH20 Hillsborough) NA NA Puketapapa Existing yes
Southwestern Shared Path NA NA Puketapapa Existing yes
Southwestern Mway (Maioro Road to Hillsborough Road) NA NA Puketapapa Existing yes
Waterview Shared Path NA NA Whau Existing yes
Waterview Shared Path NA NA Albert Eden Existing yes
Eastern Line - Meadowbank to Orakei Station NA NA Orakei Existing yes
Te Irirangi Drive Cycleway NA NA Otara - Papatoetoe Existing yes
Harbour Edge (Westhaven Dr to Harbour Bridge) NA NA Waitemata Existing yes
Orpheus Drive SH20 NA NA Maungakiekie - Tamaki Existing yes
Harbour edge (Beaumont St) NA NA Waitemata Existing yes
Ian McKinnon Drive Cycleway NA NA Waitemata Existing yes
Southwestern shared path NA NA Whau Existing yes
Upper Harbour Drive Cycleway NA NA Upper Harbour Existing yes
North Western Cycleway (Te Atatu to Lincoln Rd) NA NA Henderson - Massey Existing yes
Roscommon Road (Wiri Station Rd) NA NA Manurewa Existing yes
Druces Road Cycleway NA NA Manurewa Existing yes
Beachcroft Avenue NA NA Maungakiekie - Tamaki Existing yes
Ellerslie-Panmure Highway NA NA Maungakiekie - Tamaki Existing yes
Browns Road Scheme NA NA Manurewa Existing yes
Onehunga Mall NA NA Maungakiekie - Tamaki Existing yes
Great North Road (Avondale) NA NA Albert - Eden Existing yes
Edmonton Road Cycleway NA NA Henderson - Massey Existing yes
Pioneer Street Cycleway NA NA Henderson Massey Existing yes
Squadron Drive Cycleway NA NA Upper Harbour Existing yes
Tauhinu Road Cycleway NA NA Upper Harbour Existing yes
Albany Expressway NA NA Upper Harbour Existing yes
Browns Bay Road Cycleway NA NA Hibiscus and Bays Existing yes
East Coast Road (Silverdale) NA NA Waiheke Existing yes
Currran Street Cycleway NA NA Waitemata Existing yes
Great North Road Cycleway NA NA Waitemata Existing yes
South Eastern Highway NA NA Maungakiekie - Tamaki Existing yes
Don McKinnon Drive Cycleway NA NA Upper Harbour Existing yes
Vincent Street Cycleway NA NA Waitemata Existing yes
Cavendish Drive Cycleway NA NA Manurewa Existing yes
Cavendish Drive Cycleway NA NA Otara - Papatoetoe Existing yes
Green Lane West NA NA Orakei Existing yes
St Lukes Road Cycleway NA NA Albert - Eden Existing yes
Whangaparaoa Road Cycleway NA NA Hibiscus and Bays Existing yes
Carrington Road Cycleway NA NA Albert - Eden Existing yes
Great North Road Cycleway NA NA Albert - Eden Existing yes
Mt Albert Road Cycleway NA NA Albert - Eden Existing yes
Ocean View Road Cycleway NA NA Waiheke Existing yes
Porchester Road Cycleway NA NA Manurewa Existing yes
Esmonde Road Cycleway NA NA Devonport - Takapuna Existing yes
Stancombe Road Cycleway NA NA Howick Existing yes
Fred Thomas Drive Cycleway NA NA Devonport - Takapuna Existing yes
Fred Thomas Drive Cycleway NA NA Devonport-Takapuna Existing yes
Smales Road Cycleway NA NA Howick Existing yes
Civic Crescent NA NA Upper Harbour Existing yes
Akoranga Drive Cycleway NA NA Kaipatiki Existing yes
Highbrook Drive Cycleway NA NA Otara - Papatoetoe Existing yes
Kaipatiki Road Cycleway NA NA Kaipatiki Existing yes
Great South Road (Papakura-Karaka) NA NA Papakura Existing yes
Hingaia Road Cycleway NA NA Papakura Existing yes
Riverhead Road Cycleway NA NA Rodney Existing yes
East Coast Road Cycleway NA NA Upper Harbour Existing yes
East Tamaki Road (east) NA NA Otara - Papatoetoe Existing yes
Flat Bush School Road Cycleway NA NA Howick Existing yes
Manukau Station Road Cycleway NA NA Manurewa Existing yes
Piwakawaka Street Cycleway NA NA Waitemata Existing yes
Wharf Road Cycleway NA NA Waiheke Existing yes
Grafton Road Cycleway NA NA Waitemata Existing yes
Central Park Drive Cycleway NA NA Henderson - Massey Existing yes
Portage Road Cycleway NA NA Whau Existing yes
Flat Bush Road Cycleway NA NA Howick Existing yes
Wairau Road Cycleway NA NA Devonport - Takapuna Existing yes
Green Lane East NA NA Orakei Existing yes
Greville Road Cycleway NA NA Upper Harbour Existing yes
Rosedale Road Cycleway NA NA Upper Harbour Existing yes
Albany Expressway (Don McKinnon) NA NA Upper Harbour Existing yes
Albany Hwy NA NA Upper Harbour Existing yes
Taharoto Road Cycleway NA NA Devonport - Takapuna Existing yes
Hobsonville Road (across mway) NA NA Henderson - Massey Existing yes
Lincoln Road Cycleway NA NA Henderson - Massey Existing yes
Hibiscus Coast Hwy (SH1 to Silverdale) NA NA Hibiscus and Bays Existing yes
Parnell Rise NA NA Waitemata Existing yes
Sandringham Road Extension NA NA Puketapapa Existing yes
Sandringham Road Extension NA NA Puketapapa Existing yes
Seabrook Avenue (Titirangi) NA NA Whau Existing yes
Oceanview Road (Waiheke town centre) NA NA Waiheke Existing yes
Hellabys Road Cycleway NA NA Otara - Papatoetoe Existing yes
Vitasovich Ave Millbrook Road Cycleway NA NA Henderson Massey Existing yes
Ranfurly Road Cycleway NA NA Manurewa Existing yes
Old State Highway 16 (Brigham Creek to Coatesville) NA NA Henderson - Massey Existing yes
Old State Highway 16 (Brigham Creek to Coatesville) NA NA Upper Harbour Existing yes
Meadowland Drive Cycleway NA NA Howick Existing yes
Buckland Road Cycleway NA NA Otara - Papatoetoe Existing yes
Don Buck Road Cycleway NA NA Henderson - Massey Existing yes
Triangle Road Cycleway NA NA Henderson - Massey Existing yes
Pomaria Road Cycleway NA NA Henderson - Massey Existing yes
Universal Drive Cycleway NA NA Henderson - Massey Existing yes
Universal Dr (west of Lincoln rd) NA NA Henderson Massey Existing yes
NW Cycleway link NA NA Henderson - Massey Existing yes
Victoria Road Cycleway NA NA Devonport - Takapuna Existing yes
Western Rail Cycleway - Swanson to Ranui NA NA Waitakere Ranges Existing yes
North Western Path NA NA Henderson - Massey Existing yes
Central Park Drive (new name) NA NA Henderson - Massey Existing yes
Upper Queen Street Bridge NA NA Waitemata Existing yes
Coronation Road Cycleway NA NA Mangere - Otahuhu Existing yes
Arran Drive Cycleway NA NA Hibiscus and Bays Existing yes
Shared path ext NA NA Papakura Existing yes
Parrs Park Path NA NA Henderson Massey Existing yes
Ockleston Road Cycleway NA NA Upper Harbour Existing yes
Wainui Road Cycleway NA NA Hibiscus and Bays Existing yes
Millwater Pwy NA NA Hibiscus and Bays Existing yes
Daldy Street Cycleway NA NA Waitemata Existing yes
Wesley Street Cycleway NA NA Devonport - Takapuna Existing yes
King Edward Parade NA NA Devonport - Takapuna Existing yes
Westwave NA NA Henderson - Massey Existing yes
Corinthian Drive Cycleway NA NA Upper Harbour Existing yes
Off road cycle route NA NA Devonport - Takapuna Existing yes
Calliope Road Cycleway NA NA Devonport - Takapuna Existing yes
Winscombe Street Cycleway NA NA Devonport-Takapuna Existing yes
Albert Road Cycleway NA NA Devonport - Takapuna Existing yes
Oratia Path NA NA Henderson Massey Existing yes
Stanmore Bay NA NA Hibiscus and Bays Existing yes
Ray Clement Treeway NA NA Albert - Eden Existing yes
Vauxhall Road Cycleway NA NA Devonport - Takapuna Existing yes
Munroe Lane NA NA Upper Harbour Existing yes
Elliot Rose Ave NA NA Upper Harbour Existing yes
Francis Street Cycleway NA NA Devonport - Takapuna Existing yes
Eldon Street Cycleway NA NA Devonport - Takapuna Existing yes
Cornerstone Drive Cycleway NA NA Upper Harbour Existing yes
Owairaka Ave NA NA Puketapapa Existing yes
Dominion Road alternative NA NA Albert - Eden Existing yes
Off road cycle route NA NA Waitemata Existing yes
Elliot Street Cycleway NA NA Waitemata Existing yes
Darby Street Cycleway NA NA Waitemata Existing yes
Victoria Park NA NA Waitemata Existing yes
Takapuna Landing NA NA Devonport-Takapuna Existing yes
Corban Ave NA NA Upper Harbour Existing yes
Palmyra Way NA NA Howick Existing yes
Flat Bush cycle route NA NA Howick Existing yes
Off road cycle route NA NA Otara - Papatoetoe Existing yes
Point England Road Cycleway NA NA Maungakiekie - Tamaki Existing yes
Erima Ave NA NA Maungakiekie - Tamaki Existing yes
Tripoli Road Cycleway NA NA Maungakiekie - Tamaki Existing yes
Pilkington Road Cycleway NA NA Maungakiekie - Tamaki Existing yes
Lazurite Drive Cycleway NA NA Henderson - Massey Existing yes
Mulgan St / Margate Road Cycleway NA NA Whau Existing yes
Gaunt Street Cycleway NA NA Waitemata Existing yes
Seacliff Ave NA NA Devonport-Takapuna Existing yes
Hibiscus Coast Hwy NA NA Hibiscus and Bays Existing yes
Don Buck Road (Triangle Road to Red Hills Road) NA NA Henderson - Massey Existing yes
Viaduct Harbour NA NA Waitemata Existing yes
Eastern Rail Cycleway (Triangle Road to Sylvia Park) NA NA Maungakiekie - Tamaki Existing yes
Orly Avenue/Thomas Road Cycleway NA NA Mangere - Otahuhu Existing yes
Mascot Avenue NA NA Mangere - Otahuhu Existing yes
Friesan Avebue NA NA Mangere - Otahuhu Existing yes
Imrie Avenue NA NA Mangere - Otahuhu Existing yes
Te Whau Pathway NA NA Whau Existing yes
Off road cycle route NA NA Maungakiekie - Tamaki Existing yes
Off road cycleway NA NA Upper Harbour Existing yes
Unbuffered cycle lane - Steve NA NA Upper Harbour Existing yes
Trail NA NA Howick Existing yes
Shared path-Steve NA NA Papakura Existing yes
Battalion Drive Cycleway NA NA Papakura Existing yes
Porchester Road Cycleway NA NA Papakura Existing yes
Massey Road (across SH20) NA NA Mangere - Otahuhu Existing yes
Waddell Avenue NA NA Maungakiekie - Tamaki Existing yes
Anderson Avenue NA NA Maungakiekie - Tamaki Existing yes
Maybury Street Cycleway NA NA Maungakiekie - Tamaki Existing yes
Shared path NA NA Mangere - Otahuhu Existing yes
Shared path NA NA Papakura Existing yes
Trail NA NA Franklin Existing yes
Browns Bay Road Cycleway NA NA Upper Harbour Existing yes
Bankside Road Cycleway NA NA Hibiscus and Bays Existing yes
Bonair Crescent NA NA Hibiscus and Bays Existing yes
Manuel Road Cycleway NA NA Hibiscus and Bays Existing yes
Stella Maris Lane NA NA Hibiscus and Bays Existing yes
Te Oneroa Way NA NA Hibiscus and Bays Existing yes
Windlass Street Cycleway NA NA Hibiscus and Bays Existing yes
Ashley Avenue NA NA Hibiscus and Bays Existing yes
Glenver Ridge Road Cycleway NA NA Hibiscus and Bays Existing yes
Off-road shared path NA NA Rodney Existing yes
Shared path NA NA Kaipataki Existing yes
Taharoto Road Cycleway NA NA Devonport-Takapuna Existing yes
Auckland Domain NA NA Waitemata Existing yes
Lovers Lane NA NA Waitemata Existing yes
Queen Street (Northcote) NA NA Kaipataki Existing yes
Galway Street Cycleway NA NA Waitemata Existing yes
Federal Street Cycleway NA NA Waitemata Existing yes
Grosvernor Street Cycleway NA NA Waitemata Existing yes
Off-road shared path NA NA Hibiscus and Bays Existing yes
Viaduct Harbour Ave NA NA Waitemata Existing yes
Archibald Park NA NA Whau Existing yes
New North Road Off-Ramp NA NA Albert - Eden Existing yes
Dominion Road Cycleway NA NA Waitemata Existing yes
Dominion Rd Off-Ramp NA NA Waitemata Existing yes
Dominion Rd offramp NA NA Waitemata Existing yes
Dominion Road Cycleway NA NA Albert - Eden Existing yes
New North Rd off-ramp NA NA Waitemata Existing yes
New North Road Cycleway NA NA Waitemata Existing yes
Ian McKinnon Drive Cycleway NA NA Albert - Eden Existing yes
Market Place NA NA Waitemata Existing yes
Jean Batten Place NA NA Waitemata Existing yes
Fort Lane NA NA Waitemata Existing yes
Pitt Street Cycleway NA NA Waitemata Existing yes
Dominion Rd offramp NA NA Albert - Eden Existing yes
Green Lane West NA NA Maungakiekie - Tamaki Existing yes
Wolverton Street Cycleway NA NA Whau Existing yes
Waterview Shared Path NA NA Albert - Eden Existing yes
Margan Ave NA NA Whau Existing yes
Rankin Ave NA NA Whau Existing yes
Clark Street Cycleway NA NA Whau Existing yes
Western Rail Cycleway - New Lynn to Avondale Station NA NA Whau Existing yes
Totara Ave NA NA Whau Existing yes
Ken Maunder Park NA NA Whau Existing yes
Eric Armishawe Reserve NA NA Albert - Eden Existing yes
McCrae Way NA NA Whau Existing yes
Totara Avenue NA NA Whau Existing yes
Te Atatu Road (Interchange to Edmorton) NA NA Henderson - Massey Existing yes
Soljak Pl bridge NA NA Albert - Eden Existing yes
Ernie Pinches link NA NA Puketapapa Existing yes
Southwestern Mway (Hillsborough to Seacliffe) NA NA Maungakiekie - Tamaki Existing yes
Ernie Pinches Street Cycleway NA NA Puketapapa Existing yes
St Lukes road NA NA Albert - Eden Existing yes
Moire Park Path NA NA Henderson - Massey Existing yes
West Coast Road Cycleway NA NA Waitakere Ranges Existing yes
Upper Waikumete Cycleway NA NA Waitakere Ranges Existing yes
Onehunga Harbour Road Cycleway NA NA Maungakiekie - Tamaki Existing yes
Buckley Ave NA NA Upper Harbour Existing yes
Old State Highway 16 (Huapai) NA NA Rodney Existing yes
Hobsonville Road (east) NA NA Upper Harbour Existing yes
Could not locate NA NA Henderson - Massey Existing yes
Northside Drive Cycleway NA NA Henderson Massey Existing yes
Fred Taylor Drive Cycleway NA NA Henderson Massey Existing yes
Fred Taylor Drive Cycleway NA NA Henderson - Massey Existing yes
Woodward Road Cycleway NA NA Albert - Eden Existing yes
Esmonde Road Cycleway NA NA Devonport-Takapuna Existing yes
St Patrick’s Square NA NA Waitemata Existing yes
Maungawhau NA NA Albert - Eden Existing yes
SH1 overbridge NA NA Waitemata Existing yes
Maungakiekie Summit NA NA Maungakiekie - Tamaki Existing yes
McLeod Park NA NA Henderson - Massey Existing yes
Olympic Park NA NA Whau Existing yes
Upper Harbour Drive (Greenhithe to Albany Highway) NA NA Upper Harbour Existing yes
Red Beach Road Cycleway NA NA Hibiscus and Bays Existing yes
Wharf NA NA Devonport-Takapuna Existing yes
Mt Victoria NA NA Devonport-Takapuna Existing yes
Vauxhall Road Cycleway NA NA Devonport-Takapuna Existing yes
Milford Reserve NA NA Devonport-Takapuna Existing yes
Taharoto Road Cycleway NA NA NA Existing yes
Shakespeare NA NA NA Existing yes
Shakesepare Road Cycleway NA NA Devonport-Takapuna Existing yes
Wairau Road Cycleway NA NA NA Existing yes
Constellation Drive Cycleway NA NA NA Existing yes
Greville Road Cycleway NA NA NA Existing yes
Albany Highway NA NA NA Existing yes
New North Road Cycleway NA NA Albert Eden Existing yes
Grand Drive (Orewa) NA NA Hibiscus and Bays Existing yes

Also Grafton Bridge and K road and Symonds St Cycleways ( and a few other less popular routes) aren’t included in the acn_lines network.

Data Visualisation

To create leaflet interactive maps, I initially tried mapview R package. These maps caused memory errors when saving. I then tried tmap after transforming the CRS to long/lat based on the nz data from the spData R package. We could also change the leaflet providers but we leave it as default Esri.WorldGrayCanvas. We will use a viridis sequential palette to show light colour for high values and dark colours for low values.

Total Bike Counters in Open Street Map 2018

# Create html tmap object of the osm bike lines, with the tooltip as the name
tmap_mode("view")
## tmap mode set to interactive viewing
tm_network <- tm_shape(bikenet_wgs84 ,bbox=bbox_plots)  + tm_lines("Total", 
               id="name",
               breaks = c(0, 150000, 300000,450000,600000, 750000),
               palette = "seq",
               lwd=5)+
      # set the sequential palette https://stackoverflow.com/questions/50954730/how-to-reverse-the-diverging-color-palette-in-r-tmap
      tm_layout(aes.palette=list(seq="viridis"),
                legend.outside = TRUE)
                #"Total Bike Counters in Open Street Map 2018") #Issues with map titles
tm_network
# Save tmap for blog
#tmap_save(tm_network,"tm_network.html")
# View the map as a static version
ttm()
## tmap mode set to plotting
last_map()

#tmap_save(tm_network,"tm_network.jpg")

The Ian McKinnon Cycleway is a link between the Northwestern Cycleway and Grafton Gully Cycleway. It opened in December 2018 and without a full year of bike counters, it is not included in the map.

Total Bike Counters in AT Network 2018

# Create html tmap object of the acn_lines, with the tooltip as the ROADNAME and the bounding box as bbox_plots
tmap_mode("view")
## tmap mode set to interactive viewing
tm_acn_network <- tm_shape(acn_lines_wgs84_sum,bbox=bbox_plots)  + 
      tm_lines("Total",
               id="ROADNAME",
               breaks = c(0, 150000, 300000,450000,600000, 750000),
               palette = "seq",
               lwd=4)+
      tm_layout(aes.palette=list(seq="viridis"),
                legend.outside = TRUE)
                #"Total Bike Counters in AT Network 2018") #issues with map titles
tm_acn_network
# Save tmap for blog
#tmap_save(tm_acn_network,"tm_acn_network.html")
# View the map as a static version
ttm()
## tmap mode set to plotting
last_map()

Conclusions

We can see there are still missing counter data for many bike routes but these maps are a first attempt at visualising the use of our Auckland bike networks.

Combining the bike network datsets with the bike counter data sets has been challenging as the common keys, the names and ROADNAMEs, in some cases have very different spellings. In order to overcome these differences, replacement using reprex based on visual inspection has been performed. This is however time consuming and there are still some differences in datasets on less popular routes.

The busiest bike routes are Quay street on the waterfront then the two main routes into town, Northwestern and Tamaki Drive Cycleways.

It appears that the AT network is more comprehensive, perhaps more up to date. But what is interesting is how both networks appear to be disjointed lines rather than a connected network. Are there widely used informal bike routes that haven’t been captured in the networks? or has a connected network not been planned?

The planning of the Auckland bicycle network doesn’t appear to be data driven. More counters could be added to informal bike routes or network analysis could be performed to inform and prioritise the construction on developing this network in addition to public consultation.

References

# Package citations as seen in freerangestats.info/blog/2019/03/30/afl-elo-adjusted
thankr::shoulders() %>% 
  mutate(maintainer = str_squish(gsub("<.+>", "", maintainer))) %>%
  group_by(maintainer) %>%
  summarise(`Number packages` = sum(no_packages),
            packages = paste(packages, collapse = ", ")) %>%
  knitr::kable() 
maintainer Number packages packages
Achim Zeileis 1 colorspace
Alexander Walker 1 openxlsx
Brian Ripley 2 class, KernSmooth
Brodie Gaslam 1 fansi
Charlotte Wickham 1 munsell
David Meyer 1 e1071
David Robinson 1 broom
David Scott 1 xtable
Deepayan Sarkar 1 lattice
Dirk Eddelbuettel 2 digest, Rcpp
Duncan Temple Lang 1 XML
Edzer Pebesma 4 lwgeom, sf, sp, units
Erich Neuwirth 1 RColorBrewer
Florian Detsch 1 satellite
Gábor Csárdi 5 cli, crayon, igraph, pkgconfig, zip
Hadley Wickham 15 assertthat, dplyr, forcats, ggplot2, gtable, haven, httr, lazyeval, modelr, plyr, rvest, scales, stringr, tidyr, tidyverse
Hao Zhu 1 kableExtra
Henrik Bengtsson 3 R.methodsS3, R.oo, R.utils
Jakub Nowosad 1 spData
James Hester 1 xml2
Jennifer Bryan 2 cellranger, readxl
Jeremy Stephens 1 yaml
Jeroen Ooms 2 curl, jsonlite
Jim Hester 3 glue, withr, readr
JJ Allaire 1 htmlwidgets
Joe Cheng 6 crosstalk, htmltools, httpuv, later, leaflet, promises
Justin Talbot 1 labeling
Kevin Ushey 1 rstudioapi
Kirill Müller 4 DBI, hms, pillar, tibble
Lionel Henry 3 purrr, rlang, tidyselect
Luke Tierney 1 codetools
Marek Gagolewski 1 stringi
Mark Padgham 1 osmdata
Martijn Tennekes 2 tmap, tmaptools
Michel Lang 1 backports
Patrick O. Perry 1 utf8
R-core 1 nlme
R Core Team 12 base, compiler, datasets, graphics, grDevices, grid, methods, stats, stats4, tools, utils, foreign
Robert J. Hijmans 2 geosphere, raster
Robin Lovelace 1 stplanr
Roger Bivand 4 classInt, maptools, rgdal, rgeos
Simon Garnier 1 viridisLite
Simon Urbanek 2 base64enc, png
Stefan Milton Bache 1 magrittr
Thomas Lumley 1 dichromat
Tim Appelhans 1 mapview
Vitalie Spinu 1 lubridate
Winston Chang 3 shiny, webshot, R6
Yihui Xie 8 blogdown, bookdown, evaluate, highr, knitr, mime, rmarkdown, xfun