Carpark Vacancy in Singapore: A Geo-Spatial Analysis

Introduction

Car parks, ticketing systems, hourly rates, no vacancies. I was able to avoid most of these issues in cities I have visited, by riding the metro, or by taking a cab. The public transportation in Tokyo was so punctual and ingrained into the city’s infrastructure, it made it seem like owning a car would be completely meritless. In most cases it is! Walking around Sumida, and Taito city, I saw strange vertical solutions to parking lots more than once. I remember doing a double take the first time I saw cars stacked on shelf-like apparatuses.

That brings us to the inspiration of this article. I found this gem of an API, on data.gov.sg. It gives you the lot availability per hour for thousands of car parks in Singapore. Navigating to this page you can obtain further characteristics about each car park. The information enclosed is the unique car park number, its address, the x and y coordinates in SVY21, the type of parking system employed in the car park, if it allows short term parking (the only type we’ll be looking at), and if it allows night time parking.

Objective

Our objective during this analysis, is to find parking lots with discernable patterns in availability. While doing this, we’ll also try to answer questions such as:

  • Which nearby car parks should drivers avoid or seek, based on availability patterns during business hours and off-business hours?
  • Which car parks are at capacity during “off-business” hours? Which have a decent rate of availability?
  • What do the fluctuations in availability look like on the weekends?

By answering these questions, we hope to outline a possible way to build a powerful tool that allows drivers gain a better sense of availability for car parks near them, or their destination. During our analysis, we’ll make some broad assumptions. We’ll assume most car parks have an influx and outflow of traffic around the bounds of business hours when most people commute to work. Also, it would be rational to assume that the availability throughout the day will be similar on days during the week. Conversely, we’ll assume some car parks stay stationary, or increase during weekends, and evenings, when people are shopping or dining.

Data Set

Our initial data set CarParkAttrib contains the total lot count, and available lot count for each car park. Here’s a small glimpse at the structure of the car park data.

 kable(head(CarParkAttrib), "html") %>% kable_styling("striped") %>% scroll_box(width = "100%", height = "10%")
carpark_number address x_coord y_coord car_park_type type_of_parking_system short_term_parking free_parking night_parking car_park_decks gantry_height car_park_basement LatLong
ACB BLK 270/271 ALBERT CENTRE BASEMENT CAR PARK 30314.79 31490.49 BASEMENT CAR PARK ELECTRONIC PARKING WHOLE DAY NO YES 1 1.8 Y 1.3010571246531804,103.85411804988033
ACM BLK 98A ALJUNIED CRESCENT 33758.41 33695.52 MULTI-STOREY CAR PARK ELECTRONIC PARKING WHOLE DAY SUN & PH FR 7AM-10.30PM YES 5 2.1 N 1.3209980485169983,103.88506094748588
AH1 BLK 101 JALAN DUSUN 29257.72 34500.36 SURFACE CAR PARK ELECTRONIC PARKING WHOLE DAY SUN & PH FR 7AM-10.30PM YES 0 0.0 N 1.3282772191512717,103.84461988911718
AK19 BLOCK 253 ANG MO KIO STREET 21 28185.44 39012.67 SURFACE CAR PARK COUPON PARKING 7AM-7PM NO NO 0 0.0 N 1.3690847475169592,103.83498485033613
AK31 BLK 302/348 ANG MO KIO ST 31 29482.03 38684.18 SURFACE CAR PARK COUPON PARKING NO NO NO 0 0.0 N 1.3661139697165128,103.84663563158024
AK52 BLOCK 513 ANG MO KIO ST 53 29889.35 39382.81 SURFACE CAR PARK COUPON PARKING WHOLE DAY NO YES 0 0.0 N 1.3724321490118094,103.85029569737912

Some car parks don’t allow for short-term parking. Since our goal is to build a tool for short-term parking, so we will filter out all parking lots that don’t support this type of transaction. Let’s take a look at the count of each car park type.

total.lots <- CarParkAttrib %>% nrow()
trans.types <- CarParkAttrib %>% ggplot(aes(x = short_term_parking, fill = short_term_parking)) + geom_bar() + ggtitle(paste0("Count of Transaction Types | ", total.lots, " Total Car Parks"))
ggplotly(trans.types)

We can see that only 70 parking lots do not support short-term parking. That’s a miniscule amount, considering our sample size of 2126 unique car parks. Let’s try to gain a better understanding of car parks that support short term parking, and their spatial distribution across singapore. To accomplish this, we’ll utilize mapview. This package is great for geo-spatial visualizations, and even supports some interactive elements.

plotmapview <- function(df, strcol = NULL, graph = FALSE, graphobj){
### Grab the dataframe, and split the LatLong column into columns named Lat and Long, convert to numeric.
CarParkAttribsp <- df %>% separate(LatLong, into = c("Lat", "Long"), sep = ",") %>% mutate(Lat = as.numeric(Lat), Long = as.numeric(Long))
## Specify which columns we'll use as geo-spatial coordinates
coordinates(CarParkAttribsp) <- ~ Long + Lat
## Encoding
proj4string(CarParkAttribsp) <- "+init=epsg:4326"
## plot with z column called by function argument strcol
if(graph == FALSE){
mapview(CarParkAttribsp, zcol = strcol,  burst = TRUE)
} else{
mapview(CarParkAttribsp, zcol = strcol,  burst = FALSE, legend = TRUE, popup = popupGraph(graphobj))
}
}

We can go ahead and call this function after filtering out the car parks that don’t support short term parking, and selecting specified columns of interest in the pop-up option.

CarParkAttrib %<>% filter(short_term_parking != "NO")
plotmapview(df = CarParkAttrib, "short_term_parking")