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.

A screenshot of the Save Vector Layer as dialog box in QGIS
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

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.

A screenshot of the getting started with OS Maps for Power BI Add some data tab from the visualisation home page
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

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.

Last updated

Was this helpful?