Sharing cycling routes using newly released OS APIs
Ordnance Survey
In this month’s article we are looking at the new OS APIs which can be found on the OS Data Hub.
The data hub gives access to OS Open Data and to the OS APIs which can be used to access our content. The APIs can be used to access our data from our servers without having to download large amounts of data onto your machine. Currently available are:
- OS Maps API – raster tiles for adding to GIS, web, or mobile applications.
- OS Features API – buildings, roads, greenspaces and more! Data for querying.
- OS Vector Tile API – quick, customisable vector maps.
- OS Names API – a free, searchable, reliable database to help find and verify postcodes, populated places, road names, and more.
- OS Linked Identifiers API – free access to the relationships between properties, streets, and identifiers.
- OS Downloads API – automated discovery and download of OS OpenData.
As with previous articles, let us go through an example of how to put the use of OS Maps API into context. Here a cycling enthusiast is putting together a website to show the cycle routes that they and a group of colleagues take every week. To display the routes visually, they want to overlay the routes they take on a map, while also recording the condition and length of each route.
Questions customers need support with include:
- How can I use OS APIs in my GIS software?
- How can I integrate an OS API into my website?
- How can I incorporate non-OS data into the application?
- How can I ensure that I only allow users to access OpenData within my APIs?
How can I use OS APIs in my GIS software?
The OS Maps API is provided as a WMTS or ZXY Endpoint within the Data Hub. This allows the various layers to be added within most modern GIS software. Make sure you set your extent within the software before rendering the APIs, otherwise costs can increase quickly!
How can I integrate an OS API into my website?
OS APIs can easily be accessed in HTML using some basic JavaScript alongside other mapping APIs such as Mapbox (free with premium options) or Leaflet (free and open-source). This example uses Leaflet, but other examples can be found on OS Labs. The following code was used within the body of the example website, found at the end of the article.
How can I ensure that I only allow users to access OpenData within my APIs?
Simply choosing an Open-only map style and applying the right zoom threshold values for minZoom and maxZoom will allow you to keep your users within OpenData, which is free-to-use OS Data. You can also restrict panning using an array with southwest and northeast bounding coordinates within the object key mapOptions.maxBounds.
How can I incorporate non-OS data into the application?
This can be done using the mapping API that is being used to display the OS Maps data. In this example, Leaflet has a repository called omnivore which can be used to display multiple GeoJSON files over a map. Mapbox and other mapping tools have similar methods available to them. The example also uses mouse-over tooltips.
Incorporating a map built with the OS API into an example website results in this. Please note the cycle route data is NOT included within the API and was collected specifically for this example:
To summarise:
- OS APIs can be found on the OS Data Hub.
- They can be a powerful tool not only for viewing OS data within GIS software, but also for embedding OS data within an application without having to download the data onto a server.
- When used in conjunction with other APIs, they can be overlain with other data - whether that be points, polygons, or lines.
Our highly accurate geospatial data and printed maps help individuals, governments and companies to understand the world, both in Britain and overseas.
Benefits of the OS Data Hub
Whether you’re new to geospatial or a GIS data expert, the OS Data Hub grants access to our data. Discover our platform and the benefits of using it, along with an explanation of the types of GIS data you can get.
Products and solutions featured in this news article
OS Features API
With OS Features API, you can filter Ordnance Survey data for buildings, roads, rivers, hospitals, playing fields, and greenspaces.
OS Maps API
OS Maps API offers the most convenient way to add detailed OS data to your application. Benefit from unrivalled levels of detail in your GIS, web or mobile app.
OS Vector Tile API
A vector tile service providing detailed Ordnance Survey data as a customisable basemap.
OS Names API
A geographic directory with basic information on identifiable places. Find the closest location to a given point through the API.
OS Linked Identifiers API
Access the relationships between properties, streets and OS MasterMap identifiers for free.
OS Downloads API
The OS Downloads API lets you script and automate your downloads of OS OpenData and OS Premium data. Save valuable time by automating the process.