Shapes from data (WKT and GeoJSON)

This layer draws shapes whose geometry is held in your data as text: Well-Known Text (WKT) or GeoJSON. Use it when your boundaries, routes, floor plans or assets come from a database or change over time, so the map always shows the shapes in the current data.

A building floor plan drawn as colored polygons from WKT text held in the data
Polygons drawn from WKT in the data

What you need

Each row is one shape. Add these fields to the visual:

Field well What to put in it
* ID (required) A unique value for each shape.
Image / WKT / GeoJSON The geometry of the shape as WKT or GeoJSON text.

Add fields to Tooltips if you want them.

These fields must be empty on a shape's row, otherwise the row belongs to another layer and the shape is not drawn: Longitude (X), Latitude (Y), Destination Longitude, Destination Latitude, Circle Size, Heatmap Weight, Cell (H3/S2/A5/Geohash) Weight and Feature Reference. See Combine several layers in one map.

A row of data looks like this:

ID Image / WKT / GeoJSON
North POLYGON ((-2.6 53.5, -2.1 53.5, -2.1 53.2, -2.6 53.2, -2.6 53.5))
Pipeline 4 LINESTRING (-1.9 52.5, -1.7 52.6, -1.5 52.6)
Depot {"type":"Point","coordinates":[-1.55,53.8]}

Add the layer

  1. Add * ID (required) and Image / WKT / GeoJSON to the visual.
  2. If the panel What kind of map are you making? is showing, select the Shapes (from data) tile. Otherwise, in the Format pane expand Data Layers and, in the Data Layers group, turn on Shapes (from data) WKT / GeoJSON features.
  3. In the Shapes (from data) - Formatting group, set Fill Color, Line Color and Line Width. Use conditional formatting (fx) to color each shape from your data.

Text formats

Each row holds one complete geometry.

WKT

The text must start with one of these geometry types and end with a closing parenthesis:

POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON, GEOMETRYCOLLECTION

Upper or lower case both work. A geometry that contains the word EMPTY, such as POLYGON EMPTY, is skipped.

No SRID prefix

Text that starts with SRID=4326; is not recognized, because it does not start with a geometry type. Remove the prefix and use the EPSG setting instead. Also remove anything after the final parenthesis, including trailing spaces.

GeoJSON

Text that starts with { is read as GeoJSON. Each row can hold:

  • A geometry object, such as {"type":"Polygon","coordinates":[...]}.
  • A Feature, such as {"type":"Feature","geometry":{...},"properties":{...}}. The geometry is drawn. The Feature's own properties are not used.

A FeatureCollection is not accepted. Put one geometry or Feature on each row. To draw a whole GeoJSON file, upload it to Shapes from files instead.

What is drawn

Geometry Drawn as
Point, MultiPoint A circle, pin, text or emoji, or image. See Points.
LineString, MultiLineString A line. See Lines.
Polygon, MultiPolygon A filled shape with an outline, or a 3D extrusion. See Polygons.
GeometryCollection Each geometry in the collection.

A third number on each coordinate (a Z value) is accepted and ignored.

A row whose text cannot be read is skipped. No message is shown on the map, so if shapes are missing, check the text of those rows first.

The 32,766 character limit

Power BI stores at most 32,766 characters in a text value. A detailed shape can be longer than that. Power BI then cuts the text short, the geometry is no longer valid, and the row is skipped.

There are three ways to deal with this. You can combine them.

Simplify the shapes before they reach Power BI. Detailed boundaries rarely need every vertex on a report map. Simplify them in a GIS tool, or in the source database. For example, SQL Server has Reduce() and PostgreSQL has ST_SimplifyPreserveTopology():

-- SQL Server, Azure SQL
SELECT shape_name, wkb_geometry.MakeValid().Reduce(100).STAsText() AS wkt FROM shapes

-- PostgreSQL
SELECT shape_name, ST_AsText(ST_SimplifyPreserveTopology(geom, 100)) AS wkt FROM shapes

Reduce the number of decimal places. Coordinates are often stored with far more decimal places than a map needs. In PostgreSQL, ST_SnapToGrid(geom, 0.001) rounds them.

Split the text across rows and join it with a measure. A column holds 32,766 characters, but a DAX measure can return much longer text.

  1. In Power Query, select the geometry column, then Split Column > By Number of Characters. Enter 32000 and, under the advanced options, split into Rows.
  2. Add an index column so the pieces keep their order.
  3. Create a measure that joins the pieces back together:
Combined WKT =
CONCATENATEX ( Shapes, Shapes[geom], "", Shapes[chunk_order] )
  1. Use the shape's code or name for * ID (required) and the measure for Image / WKT / GeoJSON.

Very large shapes are slow to send and draw. For large boundary sets, consider Shapes from files instead: upload the boundaries once into the report, or use the built-in countries, states and provinces.

Coordinate systems

By default coordinates are longitude then latitude in decimal degrees (EPSG 4326). If your shapes use another coordinate system, enter its EPSG number in Format pane > Data Layers > Shapes (from data) - Configuration > EPSG, for example 27700 for British National Grid. Enter the number only. The setting applies to WKT and GeoJSON text alike.

Points

Show Points As sets how every Point and MultiPoint in the layer is drawn:

Option What it draws Settings
Pin A map pin of a fixed size. None
Icon (text or emoji) Any text, symbol or emoji, in a color you choose. Icon, Icon Size, Icon Color
Image An image held in the report: a data URI, SVG text, or the word pin. Image, Image Size
Circle A circle, using the layer's fill and line color. Circle Size

Icon Map Lite downloads nothing, so Image cannot take a link, and there is no icon library to pick from. See Images and icons for how to put images in your data.

Lines

Lines are drawn with the Line Color, Line Width and Line Transparency.

  • Linestring Shape changes how a line runs between its points. Straight draws the line as supplied. Smoothed replaces it with a smooth curve that passes through every point. Bezier uses the first and last points as the ends and the points between as control points, so the curve bends toward them without passing through them. Routes draws lines that share a street side by side, see Routes. Smoothed and Bezier apply to WKT LINESTRING and MULTILINESTRING text.
  • Color Type set to Gradient colors every line from Gradient Color 1 at its start to Gradient Color 2 at its end.
  • Line Blur softens the lines.
  • Image URL at Linestring Start and Image URL at Linestring End place an image at the first or last point of a line. Each has its own rotation, width and height. Despite the names, they take a data URI, SVG text or the word pin, not a link. End Image Pitch Alignment decides what happens to the end image when the map is tilted: Map lays it flat on the map, Viewport keeps it upright.
  • Include Line Symbol draws text or a character, such as an arrow, along each line. The options are the same as for the Lines layer. With Line Symbol Repeat on, symbols repeat at intervals that depend on the zoom, so a line may carry one or none at country scale. The default symbol, ►, is not in the built-in font and is drawn upright beside the line; use > or another plain character when it must point along the line.

Lines in this layer have no dash patterns.

Lines drawn from WKT with direction arrows along them
Linestrings with line symbols

Polygons

Polygons take the Fill Color, Fill Transparency and the line settings for their outline. Each accepts conditional formatting, so you can color every shape by a measure.

Fill Style has three options:

  • Solid - the fill color.
  • Hatched - diagonal stripes in the fill color. Hatch Width sets the width of the stripes.
  • Pattern - a repeating pattern. Enter a built-in pattern name in Pattern / Image URL, such as hatch20x045, hatch20x135 or hatchcross20. Built-in patterns take the fill color. You can also enter an image as a data URI.

3D extrusion

Polygon Extrusion Height raises a polygon into a 3D block, in meters. Polygon Extrusion Base Height sets the height it starts from, so a shape can float above the ground. Both accept conditional formatting, so the height can come from a measure. A polygon with a height of 0 or blank stays flat.

Tilt the map to see the height. See View, zoom and projection. Extruded polygons are drawn in a solid color: Fill Style does not apply to them.

The Polygon Extrusion Height box in the Format pane accepts 0 to 100,000 meters. To set heights row by row, use conditional formatting (fx).

Rooms of a floor plan extruded into 3D blocks on a tilted map, with labels
Polygon Extrusion Height on a tilted map

Selection, tooltips and labels

  • Click a shape to select its row and filter the other visuals on the report page. Hold Ctrl or Shift to add to the selection. The other shapes are dimmed. Set Selectable to No to turn this off. See Select and filter with the map.
  • Pointing at a shape shows the fields in Tooltips. Set Include Tooltip to No to turn tooltips off. See Tooltips.
  • Each shape can carry a data label. See Data labels.
  • Shapes with Include in Auto Zoom set to Yes are included when the map zooms to fit your data.

Settings

All settings are in Format pane > Data Layers. The fx column shows which settings accept conditional formatting.

Shapes (from data) - Configuration

Setting What it does Default fx
Include in Auto Zoom Includes the shapes when the map zooms to fit your data. Yes Yes
Include Tooltip Shows tooltips on shapes. Yes Yes
Selectable Lets report users select shapes. Yes Yes
Show Points As Pin, Icon (text or emoji), Image or Circle. Circle
Circle Size Circle radius in pixels, 0 to 500. Shown for Circle. 5 Yes
Image The image to draw at each point: a data URI, SVG text or pin. Shown for Image. Empty Yes
Image Size Size of the image, 0 to 500. Shown for Image. 5 Yes
Icon Any text or emoji, drawn as the point. Shown for Icon (text or emoji). Empty Yes
Icon Size Size of the text, 0 to 200. Shown for Icon (text or emoji). 5 Yes
Icon Color Color of the text. Shown for Icon (text or emoji). #000000 Yes
Polygon Extrusion Base Height Height the extrusion starts from, in meters, 0 to 100,000. 0 Yes
Polygon Extrusion Height Height to extrude polygons, in meters, 0 to 100,000. 0 Yes
Linestring Shape Straight, Smoothed, Bezier or Routes. Straight Yes
Image URL at Linestring Start Image at the first point of each line: a data URI, SVG text or pin. Empty Yes
Start Image Rotation Rotation in degrees, 0 to 360. 0 Yes
Start Image Width, Start Image Height Size in pixels, 0 to 1000. 30 Yes
Image URL at Linestring End Image at the last point of each line: a data URI, SVG text or pin. Empty Yes
End Image Rotation Rotation in degrees, 0 to 360. 0 Yes
End Image Width, End Image Height Size in pixels, 0 to 1000. 30 Yes
End Image Pitch Alignment Map or Viewport. Map
Minimum Zoom The layer is hidden when the map is zoomed out past this level. -20 to 24. 0
Maximum Zoom The layer is hidden when the map is zoomed in past this level. -20 to 24. 24
Z Index Position in the drawing order. Layers with a higher value draw on top. 0 to 1000. 400
EPSG The coordinate system of the geometry. 4326

When Linestring Shape is Routes, the card also shows Route Name, Merge Distance (m), Route Outline Color, Route Outline Width and Route Badges. See Routes.

Shapes (from data) - Formatting

Setting What it does Default fx
Color Type Solid or Gradient, for lines. Solid
Gradient Color 1, Gradient Color 2 Colors at the start and end of each line. Shown for Gradient. #0000FF, #FF0000
Line Color Color of lines and polygon outlines. Shown for Solid. Theme color Yes
Line Transparency 0 is solid, 100 is invisible. 0 Yes
Line Width Width in pixels, 0 to 100. 2 Yes
Line Blur Blur applied to the line, 0 to 100. 0 Yes
Fill Color Fill color of polygons and circles. Theme color Yes
Fill Transparency 0 is solid, 100 is invisible. 20 Yes
Fill Style Solid, Hatched or Pattern. Solid Yes
Hatch Width Width of the stripes. Shown for Hatched. 2 Yes
Pattern / Image URL The pattern name or data URI image for Pattern. Empty Yes
Include Line Symbol Draws text along each line. No Yes
Line Symbol Text The text or character to draw. Use > for an arrow that follows the line. ► Yes
Line Symbol Color Color of the symbol. Theme color Yes
Line Symbol Size Size of the symbol, 1 to 100. 20 Yes
Line Symbol Repeat Repeats the symbol at intervals along the line, depending on the zoom. No draws it once at the center. Yes Yes
Line Symbol Orientation Keep Upright or With Line Direction. With Line Direction
Symbol Halo Color Color of the outline around the symbol. #FFFFFF Yes
Symbol Halo Width Width of the halo, 0 to 100. 0 Yes
Symbol Halo Blur Blur of the halo, 0 to 100. 0 Yes

Tips and limits

  • A map has one Shapes (from data) layer. It can hold points, lines and polygons together.
  • Show Points As is one choice for the whole layer.
  • Each row is one geometry. Geometry cannot be spread across several columns.
  • The same field well, Image / WKT / GeoJSON, also feeds the Images and icons layer. A row with an image and coordinates is an image. A row with WKT or GeoJSON text and no coordinates is a shape.
  • The built-in background map shows country-level detail. For floor plans, sites and streets, choose None as the background map, or upload a custom basemap of the area.
  • The visual receives 30,000 rows by default. See Data rows and limits.