使用Power BI自定义形状贴图

时间:2020-02-18 10:09:53

标签: json powerbi arcgis topojson mapshaper

我一直试图在Power BI中使用自定义形状贴图,但无法使其正常工作。 所有这些背后的想法是从一个.shp文件,一个.dbf文件和一个.prj文件开始,然后将其导出到实际上在Power BI中工作的TopoJson文件,以通过色彩饱和度显示County之间的差异。

为此,我一直在使用https://mapshaper.org网站。

这是我从中开始的文件:

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

这就是我希望它可以在Power BI中使用的方式:

Map Shaper .shp file without .dbf file

我发现这些信息可能对我有所帮助

Power BI. Using custom map as base map

https://moriartynaps.org/

2 个答案:

答案 0 :(得分:0)

使用mapshaper时,您应该会得到一个topojson文件,该json文件是我假设您已经将其导入到形状图可视化视图中的Power BI中。

在topojson文件中,“应该”为该地图的各个部分分配一个ID或标识符。因此,请在文本/脚本编辑器中查看json文件以识别这些文件。

将数据集导入Power BI,然后您需要将每个数据值映射到标识符。显然,如何操作取决于您自己...如果愿意,可以编写一个庞大的“ if / else” dax公式,但关键是,导入数据的每一行都具有另一列,该列具有与json文件。

答案 1 :(得分:0)

您可以直接从 json 文件中获取形状映射键。下面是一个例子: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
相关问题