In my previous post on Roads Open Data I outlined the importance of providing quality data for London’s roads, particularly at a time when our Road Modernisation Plan is being implemented and we are urging drivers to check for disruption before they travel.

We continue to make improvements to our roads open data, with London Underground live car parking spaces availability now available through the Unified API, as well as live video JamCams that give a far better indication of how traffic is flowing in the Capital.

London Underground car parks

London Underground has over 60 car parks with over 11,000 spaces. With the help of our partners NCP and SmartParking, we have released live data showing available spaces for 25 of these car parks. We are seeing whether we can expand the feed to cover all London Underground car parks in the future.

We don’t have this showing on tfl.gov.uk yet, but we’ve made the feed available as open data in the Unified API so that the dev community can have a head start.

You can get the full list of Car Parks from the Places API, which can also be searched by lat/long bounding box or radius. For each car park, we return information such as the address, opening hours, payment methods and facilities, and in some cases, the live occupancy. In the example below, Barkingside Station car park, the OccupancyUrl is returned, indicating that live data is available.

{
  "id": "CarParks_800491",
  "url": "https://api.tfl.gov.uk/Place/CarParks_800491",
  "commonName": "Barkingside Stn (LUL)",
  "placeType": "CarPark",
  "additionalProperties": [
  {
    "category": "Description",
    "key": "NumberOfSpaces",
    "sourceSystemKey": "CarParks",
    "value": "46",
    "modified": "2016-01-07T15:45:43.153"
  },
  {
    "category": "Description",
    "key": "NumberOfDisabledBays",
    "sourceSystemKey": "CarParks",
    "value": "2",
    "modified": "2016-01-07T15:45:43.153"
  },
  {
    "category": "Meta",
    "key": "OccupancyUrl",
    "sourceSystemKey": "CarParks",
    "value": "https://api.tfl.gov.uk/Occupancy/CarPark/CarParks_800491",
    "modified": "2016-01-07T15:45:43.153"
  }...

The URL is based on the place id of the car park, for example “CarParks_800491” so if you know the Car Park id, you can go straight to the occupancy data. We use a separate URL because we have a much shorter time-to-live in our cache for the occupancy vs. the place data (60 seconds and 1 day respectively). In the example below, using Barkingside again, we can see that there’s no spaces available right now.

{
 "id": "CarParks_800491",
 "bays": [
    {
     "bayType": "Disabled",
     "bayCount": 2,
     "free": 0,
     "occupied": 2
    },
    {
     "bayType": "Pay and Display Parking",
     "bayCount": 45,
     "free": 0,
     "occupied": 45
    }
  ],
  "name": "Barkingside Stn (LUL)",
  "carParkDetailsUrl": "https://api.tfl.gov.uk/Place/CarParks_800491"
}

JamCams

We have improved the “JamCam” system to provide nearly live video clips from all existing cameras. The videos give a better indication of the actual traffic flow compared to static images. Each clip is five seconds long, and encoded using H.264 at the same resolution as the static JamCam images (352 x 288).

Screenshot 2016-01-13 13.28.28.png

The JamCams layer can be turned on from the Traffic Status map.

The JamCams are retrieved from the Places API, which can be searched by lat/long, for items of type “JamCam”. In the example below, we retrieve the exact camera we want using its id, and then the video URL is available in the payload key/value pair.

https://api.tfl.gov.uk/Place/JamCams_00001.04502 
{
   "id": "JamCams_00001.04502",
   "url": "https://api.tfl.gov.uk/Place/JamCams_00001.04502",
   "commonName": "Westminster Bridge/York Rd",
   "placeType": "JamCam",
   "additionalProperties": [
   {
     "category": "payload",
     "key": "imageUrl",
     "sourceSystemKey": "JamCams",
     "value": "/tfl/livetravelnews/trafficcams/cctv/0000104502.jpg",
     "modified": "2016-01-06T19:34:01.19"
   },
   {
     "category": "payload",
     "key": "videoUrl",
     "sourceSystemKey": "JamCams",
     "value": "https://s3-eu-west-1.amazonaws.com/jamcams.tfl.gov.uk/00001.04502.mp4",
     "modified": "2016-01-06T19:34:01.19"
   }...

You can see this example in the video below:

All of the information about a given camera available from the JSON API response is also included in the EXIF headers of both the videos and images. In addition, the EXIF “User Comments” field contains JSON formatted metadata: direction (a description of the orientation of the camera), the corridor on which the camera is located and the availability of the camera.

In the example above, this is an available camera with orientation “West (twds Parliament Square)” and corridor ”Southern River Route”. If your app directly references the video by id it may be easier to retrieve this metadata from the EXIF header rather than also calling the Places API separately. Below is some of the output of using the open-source exiftool utility on the video:

GPS Latitude                    : 51 deg 30′ 3.24″ N
GPS Longitude                   : 0 deg 7′ 3.42″ W
User Comment                    : {“direction”:”West (twds Parliament Square)”,”corridor”:”Southern River Route”,”available”:true}
Artist                          : Ben Barker
Copyright                       : Transport for London
Image Description               : Westminster Bridge/York Rd
Software                        : 1.0
Avg Bitrate                     : 56 kbps
GPS Latitude Ref                : North
GPS Longitude Ref               : West
Image Size                      : 352×288
Megapixels                      : 0.101
Rotation                        : 0
GPS Position                    : 51 deg 30′ 3.24″ N, 0 deg 7′ 3.42″ W

 

The video clips and images will normally update every five minutes. However, if a camera is in use by our control centre, the video will not be updated. Published clips will never be more than 15 minutes old – if they are, they are replaced by a blanking image. We’re currently seeing availability of around 90% (out of 950 cameras), though this will vary depending on what is occurring on the transport network.

Legacy data feeds

We’ll be turning off the legacy data feed in future so please register on the developer portal and use the new Unified API. We’ll give developers a heads up in advance, but please start the process of migrating any of your existing apps as soon as you can. A minor change will occur even before the legacy feed is disabled, the file nomenclature for the images has changed slightly – from “0000107500.jpg” to “00001.07500.jpg” (there is an extra period in the filename that brings it in line with the video naming convention).

We’d love to find out what you’re building with this data, what is most useful to you and if you feel that anything important is missing from the Unified API. Please let us know what you think, or ask any questions you have on our roads data in the comments below.

Posted by Tim Williams

Lead Developer on the Transport for London Unified API

13 Comments

  1. great article a good read

    Like

    Reply

  2. […] data offering. (You can read about our roads open data in this post on our Unified API as well as in this post, describing recent improvements we’ve made to this […]

    Like

    Reply

  3. The video jamcams are a great improvement over static images, they really help to quickly visualise traffic flow.
    I have just integrated the video functionality into my iOS app UK Roads (https://itunes.apple.com/gb/app/uk-roads-traffic-news-cameras/id482911568?mt=8) and it’s working really well. Thanks!

    Liked by 2 people

    Reply

    1. Hi Andy I believe we met at the AWS Loft event and you had some questions about the jam cams feed. If you send your contact details to theochapple@tfl.gov.uk, I’ll put you in touch with my colleague in Road Space Management who developed and supports the feed. Thanks!

      Like

      Reply

  4. Thanks for this awesome post. It is extremely helpful for me. Would you mind updating your blog with more information

    Like

    Reply

  5. […] The London Panopticon utilises the traffic camera feed from the TfL API, which recently added ~6-second-long video clips from the traffic cameras on TfL “red route” roads, to show the current state of traffic near you. The site loads the latest videos from the nearest camera in each compass direction to you. The images are nearly-live – generally they are up-to-date to within 10-15 minutes. If the camera is “in use” (e.g. being panned/zoomed or otherwise operated by an official to temporarily reprogramme the traffic lights, see an incident etc) then it will blank out. The site is basically just JavaScript, when you view it, your browser is loading the videos directly from TfL’s Amazon cloud-based repository. Blog post. […]

    Like

    Reply

  6. Very useful API and most importantly very useful data. An integration with payment system could have been great so overall parking time could be reduced.

    thanks

    Like

    Reply

  7. Hi,
    Nice blog. But a small query. How can we get the car park id if we want to get car parking details based on car park id?

    Like

    Reply

    1. As stated above: You can get the full list of Car Parks from the Places API, which can also be searched by lat/long bounding box or radius.

      Like

      Reply

      1. Hi, Thanks for your reply. But can you please tell me why I cant get car parking occupancy details for all car park id’s?
        Below is the url for which I cant get the occupancy details:

        https://api.tfl.gov.uk/Occupancy/CarPark/CarParks_800449

        Like

    2. Unfortunately occupancy data from SmartParking and NCP is only available for around 25 of the car parks.

      Like

      Reply

  8. Hi,

    I dont understand why car park occupancy details are not available for every car park id. For example :
    https://api.tfl.gov.uk/Occupancy/CarPark/CarParks_800449

    Like

    Reply

    1. Unfortunately this is a limitation of the source systems. Not all car parks have the infrastructure in place to report their occupancy.

      Like

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s