All pages
Powered by GitBook
1 of 10

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Adding an OS basemap

Follow the steps below to add an OS basemap:

1

Create a project on the OS Data Hub

Once logged in to the OS Data Hub website, select Data from the main menu, then select APIs > API Projects from the secondary navigation menu, then click the Create a new project button.

Creating a new project in the OS Data Hub.
2

Name your project

For this example, the project has been named 'Power BI'.

Naming a project dialog in the OS Data Hub.
3

Add an API to the project

Select OS Maps API from the available OS APIs, then click the Add to project button on the right-hand side of the view.

Selecting an API to add to a project in the OS Data Hub.

4

Copy the project API Key for use in Power BI

Navigate to the project page and open the project that was recently created for Power BI. The project view will have a project API Key available. Copy this API Key to the clipboard.

An example of a project API Key in the project view of the OS Data Hub.

5

Paste the OS Maps API Key into the OS Maps for Power BI Visual

Within the OS Visual setting menu in Power BI, open the Visualizations pane and navigate to Format visual > Map Settings. The first entry of the Map Settings menu is an input text box called 'OS API Key’. Paste in your project API Key from the OS Data Hub into this text box.

Once your project API Key has been added, an OS basemap should render automatically.

Map Settings menu in the Visualizations pane of Power BI.

Using Premium data

Public Sector Organisations / PSGA (Public Sector Geospatial Agreement) Members

If you want to fully zoom into the map, please make sure that the ‘Use Premium data’ toggle setting located beneath the OS API Key input box (in the Visualizations pane) is switched to On. If you registered on the OS Data Hub using a Public Sector Plan account (i.e. you are a PSGA Member), then there is no additional charge for using Premium data.

Non-PSGA Members

For non-PSGA Members using the free OS OpenData plan, please note that the maximum zoom levels will incur a cost as they are classed as Premium data. You should ensure that the ‘Use Premium data’ toggle setting located beneath the OS API Key input box (in the Visualizations pane) is switched to Off.

For more information on which zoom levels are OS OpenData and which are Premium data for the OS Maps API, please see the tables on the OS Maps API Layer and Styles page.

Installation

These instructions detail how to install OS Maps for Power BI Visual.

Installing OS Maps for Power BI Visual is straightforward and requires only a few steps. You should have received a link to Dropbox that contains a .pbiviz file with the name of your organisation on it. The .pbiviz file contains the visual that you'll import into Power BI.

Installing OS Maps for Power BI Visual

1

Click the three small dots under the Visualizations pane in Power BI

The context menu should provide options to import or remove a visual from Power BI.

2

Click 'Import a visual from a file' from the right-click context menu

The file explorer should open to allow you to navigate to the folder containing the .pbiviz file.

3

Select the .pbiviz file

Select the OS Maps for Power BI Visual from the relevant folder, then click OK to import it into the app.

After installing the visual, click the OS icon and add it to a report. When you add a visual to a report, you’ll be presented with a landing page:

Linking the Power BI Visual to the OS Maps API

Rendering a basemap requires an OS Maps API Key, available from the . If you already have access to the OS Data Hub, skip to the page; otherwise, sign up for access to the OS Data Hub using the instructions below.

Signing up for the OS Data Hub

For public sector customers (i.e. PSGA Members):

  • Register via the appropriate .

  • You’ll need to be invited by the administrator of your organisation’s OS Data Hub account. (It’s usually someone in your GIS / Geospatial Team.) If you can’t find your OS Data Hub Administrator or want to know their contact details, please contact or your OS Account Manager.

For individuals and commercial organisations:

  • Register via an to use the OS Maps API for free.

Please note that the maximum zoom levels will be capped for maps using the free OS OpenData plan. The maximum zoom levels will incur a cost as they are classed as Premium data. A Premium data toggle is present within the visual to control this, so you can choose whether to use Premium data or stick to free OS OpenData.

For more information on which zoom levels are OS OpenData and which are Premium data for the OS Maps API, please see the tables on the .

  • Users requiring maps without restrictions will require a Premium OS data licence. This can be acquired via an .

Premium OS data licence for internal business use

Customers shouldn’t sign up for an OS Premium Data Plan directly on the OS Data Hub to use the OS Maps for Power BI Visual for internal business use, as this is not covered under the plan's licence.

OS Data Hub
Adding an OS Basemap
Public Sector Plan on the OS Data Hub
[email protected]
OS Open Data plan on the OS Data Hub
OS Maps API Layer and Styles page
OS Partner
Importing a visual using the OS Maps plugin from the Power BI visualizations pane. Image shows the 'Import a visual from a file' option highlighted from the context menu of the OS Maps for Power BI Visualisation plugin.
Importing a visual using the OS Maps plugin from the Power BI Visualizations pane.
OS Visual landing page in Power BI. The main page shows options to add an OS API Key with later steps to create and customise a visualisation.
OS Visual landing page.
A screenshot of the OS Data Hub projects page showing the 'Create a new project' button in the upper right hand corner
A screenshot of the create project naming dialog box showing a text box and instructions for naming your OS Data Hub project.
A screenshot of the OS Maps API available to be added to the project, shown in the OS Data Hub view.
A screenshot of part of the project view of the OS Data Hub. An example API key is shown.
Map Settings menu in the Visualizations pane of Power BI showing the text box where you can enter an API Key.

Creating a point map

Follow the steps below to create a point map:

Adding points on a map using UPRNs or Postcodes

If your data has a list of postcodes or UPRNs (unique property reference numbers), then you’re able to plot these on a map by simply dragging and dropping the relevant column in your data into the Points: Postcodes or UPRNs field of the visual.

The 'Points: Postcodes or UPRNs' data field in Power BI.

Displaying point data on a map

  • Postcodes are plotted according to their corresponding centroid.

  • The visual can display up to 30 000 individual points on the map.

  • Please note, if points appear on the same location, Points: pop-ups will have to be populated with a data attribute that splits out the points (see 'Adding clickable point pop-ups' on the Creating a point map using categorical data page).

Missing UPRN or postcode points

If you have incorrect or out-of-date postcodes and UPRNs in your data, they won’t geocode as points on the map. Clicking on the notification panel (the bell icon in the bottom left of the Power BI UI) will let you know which UPRNs or postcodes failed to geocode and are incorrect.

A screenshot of the notification panel in Power BI showing incorrect postcodes that failed to geocode.

More detailed information, such as how many postcodes / UPRNs the visual attempted to geocode and how many succeeded, can be found by clicking on the notification panel after turning on the 'Show more detailed messaging' toggle found under Format visual > Map Settings in the Visualizations pane.

Map Settings menu in the Visualizations pane in Power BI showing the 'Show more detailed messaging' toggle turned on.

Adding points on a map using Longitude / Latitude or Eastings / Northings

If your data has a list of Longitude / Latitude or Eastings / Northings, then you’re able to plot these on a map by simply dragging and dropping the relevant columns in your data into the Points: X and Points: Y fields of the visual.

X and Y point data fields in Power BI.

Displaying longitude / latitude data on a map

  • The visual can display up to 30 000 individual points on the map.

  • To see any errors, turn on the 'Show more detailed messaging' toggle under Format visual > Map Settings in the Visualizations pane.

  • If the fields won’t populate with your data, make sure that on Table View the data type for your longitude / latitude data is set to Decimal number and NOT Text.

A screenshot of the Longitude type field set to Decimal number in Power BI.
A screenshot of the 'Points: Postcodes or UPRNs' data field in Power BI, allowing users to plot Postcodes or UPRNs on their map.
A screenshot of the notification panel in Power BI showing a series of incorrect postcodes that failed to geocode
Map Settings menu in the Visualizations pane showing the 'Show more detailed messaging' toggle turned on.
A screenshot of X and Y point data fields in Power BI.
A screenshot of the Longitude type field set to Decimal number in Power BI.

How to add a polygon reference layer to the map

The reference layer feature provides a way to consistently display polygons/boundaries (e.g. LSOAs, wards, etc.) regardless of how point data is filtered on the page.

Custom geometry

This only works for ONS GSS codes and boundaries (e.g. W00008779). If custom geometry is required, then this is not supported by the reference layer.

The reference layer feature can be found under the Visualisations pane > Format Visual > Reference Layer Settings

For a reference layer to be generated, the relevant GSS codes need to be input into the ‘GSS Codes to add as map’ text box.

GSS codes can be copied and pasted directly from a spreadsheet into the text box, and it will automatically work.

Once the codes have been input, the visual should update after a few seconds with the relevant polygons displayed on the map as a reference layer that is not linked to any other data used in the visual.

Historic ONS GSS codes

The reference layer does not support historic ONS GSS codes. If polygons are missing, an old or incorrect code has been used and should be checked with the ONS.

OS Maps for Power BI Visual Getting Started Guide

This getting started guide provides instructions for using the OS Maps for Power BI Visual product. Users with limited technical knowledge will be able to follow this guide.

This getting started guide provides guidance on how to install and use the OS Maps for Power BI Visual. Topics covered in the guide include:

  • Installation

  • Adding an OS basemap

  • Creating a point map

  • Creating a point map using categorical data

  • How to create a choropleth (fill) map using ONS geographies

  • Combining points and polygons on a single map

  • How to add custom geometry (GeoJSON or WKT) to a map

  • How to add a polygon reference layer to the map

  • Using the lasso tool on the map to filter data

Combining points and polygons on a single map

It’s possible to combine a point and a polygon layer on a single map. However, depending on your use case, the data model being used may need to be correctly formatted to make it work.

Note

The visual only supports 1 layer of points and 1 polygon.

If your use case involves being able to filter point data but you need boundaries (polygons) to always display on the map, regardless of how the point data is filtered on the page, then see the .

If you need the polygons to also filter on the map then continue below.

For both points and polygons to be displayed on the map and also allow filtering based on user selections, both point and polygon data must come from the same data model. This can be achieved by either having both point and polygon data in the same data table or by using the Power BI data model view to link the data together.

Data can be combined outside of Power BI or by using built-in Power BI functionality –

If using Power BI’s data model view to relate data sets to one another, then the following Power BI help article may help – .

Selecting points within a polygon

Selecting a polygon on the map that has points in it won’t necessarily update your other visuals. You must then use the lasso tool to create a selection.

How to add a polygon reference layer to a map page
Append queries - Power Query | Microsoft Learn
Model view in Power BI Desktop - Power BI | Microsoft Learn

Using the lasso tool on the map to filter data

The visual has been designed so that clicking on a point or polygon on the map displays a pop-up with additional useful information about that location instead of filtering data in other visuals on the page.

The lasso tool allows you to filter the data on other visuals based on a selection taken from the map.

1

Select the lasso tool by clicking on the lasso icon in the top right of the map.

Your cursor should change shape once the lasso button has been clicked.

2

Draw a ‘lasso’ by holding down the left mouse button and dragging the cursor around all the points / polygons that you want to filter the other visualisations on the page by.

A cyan coloured shape will be created during the process.

3

Once you’re happy with your selection, release the left mouse button.

Any points/polygons completely within the boundaries of the lasso shape created will now be highlighted cyan and the other visualisations on the page will be update reflecting the selection made.

Maximum number of data points

The lasso tool can only select up to 500 different data points on the map at a time to ensure adequate performance.

An example of data selected using the lasso tool
A screenshot showing data selected using the lasso tool

Creating a point map using categorical data

Categorical data is data that's divided into groups, such as age, gender, occupation, etc.

Creating a map of categorical data

To create a map of categorical data, you first need to plot the data points on a map. The previous page, Creating a point map, provides detailed instructions on how to add data points to a map.

Once you have created a point map, drag the column in your data that contains the different categories into the Point: Colour field of the visual. The map will automatically recolour the points based on the different categories in your data.

Using categorical data

  • Up to 12 different categories within your data are currently supported.

  • The only way to change the colour of categorical data (points and polygons) is by specifying the relevant colour hex code (for example, #cdf1f0) in the data and dragging the column of data that represents the colours to be used into the relevant Points / Features: Colour field in the visual. There is currently no way for you to customise the colours that are displayed for categories by default via the user interface.

  • Adding hex codes into your data to manipulate the point colours won’t update the category colours within the legend.

Varying the size of points

It’s quite common that you might want to vary the size (radius) of the points on a map to represent an increase in occurrence or density (for example, larger points represent a greater number of crimes at a location).

To do this, having plotted points on a map, drag a data column containing numeric data into the Points: Size field of the visual. Then click on the downward arrow of that field and select Count. Now the size of your points will be based off the total count of data points at the locations of your points.

Points: Size field in the visualisation toolbar in Power BI.

Varying point size in the OS Maps for Power BI Visual

  • You can combine the colouring of points based on categorical data and the size of points by another data attribute to represent two different variables in a single point within your data.

  • Point size only accepts a numeric data type.

See an example below showing a combination of categorical data (crime type) and point size variation (count of crime).

A Power BI visualisation showing categorical data used with point size variation.

Adding clickable point pop-ups

Additional information about a point can be displayed as a pop-up when a point on the map is clicked.

To add a pop-up to a point on the map, drag and drop data into the Points: Pop-ups field in the Visualization pane. Information included in the pop-up field should be shown when a user clicks on a point.

Point pop-ups

  • Multiple data columns can be shown under pop-ups.

  • By enabling point pop-ups based on different data attributes, points that appear in the same location can be filtered on the map (see screenshot below, where points can be filtered on the map by crime type data).

Point data filtered by crime type data.

Handling overlapping points on a map using pop-ups

It’s quite common that points on a map will overlap, making the data more difficult to understand. For example, when considering crime data, a shoplifting crime and a violent crime may have been recorded to the same x, y coordinates; however, one point will be plotted above the other and will therefore obscure some of the data.

By dragging a relevant column of data into the Point: Pop-ups field, you can click on a point on the map to reveal a pop-up and then paginate through all the underlying points that were originally obscured.

Below is an example of a pop-up where data representing crime type is being used to enable pagination of overlapping points; the pop-up shows there are five points representing different crime types in the same location:

An example of a pop-up showing data for multiple points on a map in the visual in Power BI.

Changing the colour of categorical data on a map

If you add a column of data containing textual data representing categories (for example, School, Library, Gym) into the Points: Colour field, the points on the map will automatically colour based on a default colour palette, and a legend will be generated on the map showing what colour represents what category (for example, School = Green).

Examples of colour-coded data added to the visual in Power BI.

However, the colours can also be customised by specifying hex codes within the data. The only way to change the colour of categorical data (points and polygons) is by specifying the relevant colour hex code (for example, #cdf1f0) in the data and dragging the column of data that represents the colours to be used into the relevant Points / Features: Colour field in the visual. There is currently no way for you to to customise the colours that are displayed for categories by default via the user interface.

Generating a colour legend

Adding hex codes into your data to manipulate the point colours won’t generate the legend with the correct category colours.

A screenshot of the Points: Size field in the visualisation toolbar, showing Count of Crime Count in the dropdown box
A Power BI visualisation showing categorical data used with point size variation. Image shows crime type data displayed on the map with point size variation used to show variance in the count of crime data
A screenshot of point data filtered by crime type within the visualisation in Power BI.
An example of a pop-up showing data for multiple points on a map in the visual in Power BI.
A screenshot showing examples of colour coded data added to the visual. Image uses Crime type data to colour code different categories of crime

How to create a choropleth (fill) map using ONS geographies

It’s easy to create a choropleth (or fill) map using Office for National Statistics (ONS) geographies – Lower layer Super Output Areas (LSOAs), wards, etc. – in the OS Maps for Power BI Visual, without requiring a separate geometry file.

To make the following steps work, your data will need a column that includes ONS Government Statistical Service (GSS) codes.

GSS codes

GSS (Government Statistical Service) codes are nine-character alphanumeric codes which correspond to geographies that ONS supports, for example, an LSOA code looks like this: E01000917.

Examples of LSOA codes are shown in the table below:

LSOA Code
LSOA Name

E01000916

Camden 027B

E01000917

Camden 027C

E01000917

Camden 027C

E01000914

Camden 028B

To display these geographies as polygons on a map, simply drag and drop the column of data that has these codes into the Features Layer: GSS identifiers geocoding field of the visual.

An example of polygons displayed on a background map within the OS Maps for Power BI Visual.

Incorrect codes

Any incorrect codes won’t display a polygon on the map. The notification panel will display what codes did not work. Currently, the OS Maps for Power BI Visual does NOT support historic codes.

To colour the map and create the choropleth, drag the relevant column of data into the Features Layer: Colour field. This field can accept either numeric or text data. It’s important that every row within your data table has a GSS code (representing the polygon) and the relevant data to colour the polygon (numeric or text).

Interpreting numeric data

If using numeric data, then the Features Layer: Colour field allows several mathematical operations to be performed on the data (for example, Sum, Average, Count, etc.) to interpret it; these may need to be utilised to display the desired data correctly on the map.

How to filter map boundaries by an overarching geography

It’s quite common that a report reader will want to view a defined geography (for example, a local authority such as Cardiff) but see data on the map that represents an underlying geography, such as wards. To do this, it’s important that the underlying data is structured in the correct way. Each row should have both the geography to be displayed on the map (for example, ONS ward code – W05001272) and the geography to filter by (the local authority that the ward code belongs to; which in this case is Cardiff). The data might look like the following table:

Ward
Ward Code
Households
Local Authority

Trowbridge

W05001296

7 009

Cardiff

Whitchurch and Tongwynlais

W05001297

6 832

Cardiff

Allt-yr-yn

W05001627

3 989

Newport

Alway

W05001628

3 403

Newport

A filter can then be created to display the data, such as having a table listing the local authorities alongside the map. When a user clicks a local authority, the relevant wards and any associated data making up that local authority will be displayed on the map.

How to style a choropleth map

Once appropriate data has been dragged into the Features Layer: Colour field, then the map’s colours should update. To customise these colours, go into the Format Visual > Styling: Features Layer section.

Using text data to style the map

If using text data to colour the map, then a maximum of 12 colours will be automatically generated. These colours cannot be manually changed.

By changing the Min or Max Feature Colours, the map colours will update based on the minimum and maximum values of the data used. Opacity can also be altered to style the map.

Outlying data points

The Feature % Clip can be used to ignore outlier data points. It ignores the selected % minimum and maximum data points in the data. As an example, if 5% is specified, then the minimum 5% and maximum 5% of data points will be ignored when colouring the map.

Crime count by area displayed as shaded polygons against a background map of an area of London in the OS Maps for Power BI Visual.
An example of polygons displayed on a background map within the OS Maps for Power BI Visual. Image shows an area of London with polygons overlayed showing wards around the area of the City of London
Crime count by area displayed as shaded polygons against a background map of an area of London in the OS Maps for Power BI Visual.

How to add custom geometry (GeoJSON or WKT) to a map

There are two valid data formats that the visual accepts to display custom geometry on the map – WKT and GeoJSON. These geometries need to be properly formatted within your data in order to be displayed on the map.

Custom geometry files

The visual does not support the ability to upload a file that represents custom geometry (for example: GeoJSON, TopoJSON or Shape files).

How to use WKT data to add custom geometry to a map

The OS visual supports the ability to add custom geometry onto the map.

WKY geometry data

Your data needs to include a column that consists of WKT geometry to display it on the map using these steps.

It’s quite common that a user might have their geometry in GeoJSON, Shape or another format. These steps will demonstrate how to turn those formats into WKT that the visual will accept.

Complex geometry

If your geometry is particularly complex, it may not fully display using this method due to an inherent limitation within Power BI. Results may be improved by reducing the complexity of your geometry using a service such as Map Shaper – https://mapshaper.org

If you need to simplify your geometry, it’s best to do so at the start of this process. Load your geometry into a tool such as QGIS. Then, under Layers, right-click and select Export, then Save Feature as. Save your file as a CSV, then under ‘Geometry’ you want to select AS_ WKT.

Save Vector Layer as dialog box in QGIS

Exporting your file as a CSV will create a file with every polygon listed as a separate entry alongside any additional metadata associated with those polygons from the original file. The WKT column in that CSV is what you’d drag into the Features Layer: GeoJSON or WKT Geometry in the OS Visual to display the geometry.

Maximum cell size in Power BI

There’s a Power BI limitation where each ‘cell’ in a table of data has a maximum size of 32 KB. This means if any of your polygons is larger than 32 KB then they will not display properly and the geometry will need to be simplified.

Joining points and polygons on a map

If you want to join points and polygons on the same map, then this CSV (the polygons) will either need to be joined to your other data (the points) under the Power BI data model or merged into the same table of data.

How to use GeoJSON data to add custom geometry to a map

This step may be easier to follow by navigating to the ‘Add Some Data Tab’ on the landing page then looking for the ‘GeoJSON’ section. The landing page can be accessed via the ‘Question Mark’ button in the bottom left.

Getting started with OS Maps for Power BI Add some data tab

There are two ways you can use GeoJSON in this visual:

Using a JSON formatted geometry column within a table

You can visualise features using a JSON formatted geometry column within a table - this can be just the geometry, for example:

 {"type": "Polygon", "coordinates": [...]}

or may be a Feature, for example:

 {"type": "Feature", "properties": {...}, "geometry": ...}

If the Feature has properties, these will be added to map popups by default, but will be replaced if a column is dragged into the Features Layer: Pop-ups field.

Complex geometry

There’s a 32 KB limitation on the size of the field, meaning complicated geometries will be truncated. You may need to simplify your geometries to get them to display.

Load an entire GeoJSON file

This option requires some extra steps:

1

Go to Get data > JSON > Connect and navigate to your GeoJSON file.

This should open your data in query view and your features will be automatically expanded, giving you columns like 'features.geometry.type'.

Performing this action may have expanded your GeoJSON more than necessary, so in the Query Settings panel (probably on the right side of the window), click the cross next to 'Expanded features.geometry.coordinates' in Applied Steps to remove the step that expands your coordinates.

2

Make a custom column to drag into the visual's GeoJSON field

In the toolbar at the top go to ‘Add Column’ Custom Column. In the dialog box, add a name such as 'geom' and enter the following formula:

{" & """type""" & ":" & """" & [features.geometry.type] & """" & "," & """coordinates""" & ":" & Text.FromBinary(Json.FromValue([features.geometry.coordinates])) & "

Click OK, go back to the Home tab and Close & Apply, then drag your new 'geom' column into the Features Layer: GeoJSON or WKT Geometries field in Build visual.

A screenshot of the Save Vector Layer as dialog box in QGIS
A screenshot of the getting started with OS Maps for Power BI Add some data tab from the visualisation home page