Search code examples
jsonpowerbiarcgistopojsonmapshaper

Using a Power BI Custom Shape Map


I have been trying to use a custom shape map in Power BI and I can not get it to work. The idea behind all this is to start from a .shp file, .dbf file and a .prj file and export it to a TopoJson file that actually works in Power BI in order to show the difference between County through color saturation.

I have been using the https://mapshaper.org site in order to do this.

This are the files that I have started from:

https://drive.google.com/open?id=17EtWd5YqEV4k5ctuJIFI9JDJIK8joCnG

This is what I would like it to work in Power BI with:

Map Shaper .shp file without .dbf file

I found this information that may have helped me if I could understand it

Power BI. Using custom map as base map

https://moriartynaps.org/


Solution

  • You can get the shape map keys directly from json file. Here is an example: NZ.json

    let
        Source = Json.Document(File.Contents("C:\NZ.json")),
        #"Converted to Table" = Record.ToTable(Source),
        Value1 = #"Converted to Table"{3}[Value],
        #"Converted to Table1" = Record.ToTable(Value1),
        Value2 = #"Converted to Table1"{0}[Value],
        geometries = Value2[geometries],
        #"Converted to Table2" = Table.FromList(geometries, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
        #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table2", "Column1", {"arcs", "type", "properties"}, {"arcs", "type", "properties"}),
        #"Removed Other Columns" = Table.SelectColumns(#"Expanded Column1",{"properties"}),
        ColumnNames = Record.FieldNames(#"Removed Other Columns"[properties]{0}),
        ExpandProperties = Table.ExpandRecordColumn(#"Removed Other Columns", "properties", ColumnNames, ColumnNames)
    in 
        ExpandProperties