How to add custom geometry (GeoJSON or WKT) to a map
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
The visual does not support the ability to upload a file that represents custom geometry (for example: GeoJSON, TopoJSON or Shape files).
The OS visual supports the ability to add custom geometry onto the map.
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.
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.
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.
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.
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.
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.
There are two ways you can use GeoJSON in this visual:
You can visualise features using a JSON formatted geometry column within a table - this can be just the geometry, for example:
or may be a Feature, for example:
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.
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.
This option requires some extra steps:
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.
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:
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.