Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Good morning,
I have succeeded in importing the following (extract) TopoJSON file to create a shape map:
{"type":"Topology","objects":{"barris":{"type":"GeometryCollection","geometries":[{"type":"Polygon","arcs":[[0,1,2,3,4,5,6]],"properties":{"ID_ANNEX":"01","ANNEXDESCR":"Grup - I","ID_TEMA":"0104","TEMA_DESCR":"Unitats Administratives","ID_CONJUNT":"010413","CONJ_DESCR":"Barris","ID_SUBCONJ":"01041301","SCONJ_DESC":"Barri","ID_ELEMENT":"0104130101","ELEM_DESCR":"Límit de barri","NIVELL":"ADM_03_PL","NDESCR_CA":"Límit de barri (polígon)","NDESCR_ES":"Límite de barrrio (polígono)","NDESCR_EN":"Neighborhood boundary (polygon)","TERME":"080193","DISTRICTE":"01","BARRI":"01","AEB":"-","SEC_CENS":"-","GRANBARRI":"01","ZUA":"-","AREA_I":"-","LITERAL":"01","PERIMETRE":5521.647,"AREA":1100286.137,"ORD_REPRES":3,"CODI_UA":"01","TIPUS_UA":"BARRI","NOM":"el Raval","WEB1":"http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-del-raval","WEB2":"http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2015/barri1.pdf","WEB3":"http://www.bcn.cat/estadistica/catala/documents/barris/01_CV_Raval_2017.pdf","DOCUMENTA":null,"RANGESCALA":"1-50000","TIPUS_POL":null,"GRUIX_ID":"6","GRUIXDIMEN":70,"ESTIL_ID":"0","ESTIL_QGIS":"Sòlid","VALOR1QGIS":"0","VALOR2QGIS":"0","COL_FARCIT":"41","FCOL_DESCR":"NULL","FHEX_COLOR":"#E66900","COL_DESCR":"NULL","HEX_COLOR7":"#73A88F"}}
Having done some clearing up, I have now got the following table:
Unfortunately this is where I get stuck (I know nothing about the data structure which is needed to create the shape map, and the what and where is needed by the visual to replicate the shapes).
Any pointers?
Thanks!
Proud to be a Super User!
Paul on Linkedin.
Solved! Go to Solution.
Ignore the other thread that you mentioned. You are trying to make this way too complicated.
You do not need to know anything about TopoJSON to make this work. Please re-read my previous answer (with the following additions/clarifications).
You need two things to make shape map visualisations:
1: A topoJSON file of the place/area/shape you are going to use. If you are lucky, a nice person on the internet will already have made one that will work for your purposes. It looks to me that you already have this because you have posted a picture of it rendering correctly on GitHub. So you are halfway there (and all you had to do was search the web).
2: Some data that relates to the shape you already have (in 1: above). This is not extracted from the TopoJSON file. It is the data that you want to connect to the shape file. See my previous post's example of "Number of coffee shops in each barrio". Your data will relate to barrios of Barcelona in some way but it will not come from editing the topojson. Remove this idea from your mind.
Get the data in 2: into your powerbi file.
Drag a shapemap on to the report surface.
Add a field to the Location field well.
Use the "+ Add map" in the format section to link the shapefile in 1:
Add another field to the Color Saturation field well.
That's it.
I highly recommend that you follow the instructions here
"Unfortunately this is where I get stuck (I know nothing about the data structure which is needed to create the shape map, and the what and where is needed by the visual to replicate the shapes)."
- This statement is a little confusing. If the topojson file you have is valid, then the shape map will display in powerbi by adding the file to the Shape section (using + Add map) under the Format menu. The tricky bit is that the Shape section doesn't appear until you have some data added to one of the shape map field wells (I don't think it matters which field well and it doesn't even have to be the actual data you want to display - for example, to test with your topojson file, get some data, any data. Place a shape map visualisaton in the report. Pull a data field onto the shape map. Go to the Format section. Look under Shape. Add your map here (using + Add map). If the map displays correctly in the visualisation, you are halfway there.
Now you have to get the real data that you want to show.
I think this might be what's confusing for you because the data that you show in the question you asked seems to be edited from the actual topojson map that you display. That's OK if there is something that you want to visualise but usually the data is taken from a separate source that links to the map that you choose, e.g. Number of coffee shops in each barrio.
To visualise any data on the shape map, drag a field to the Location field well (this must match up with something in the hidden data of the topojson file - to see these items use the 'View map keys' in the Format section->Shape.
Then you add the field you want to visualise to the 'Color saturation' field well.
OK it's a long answer. Get back to me if it's unclear.
Thank you for your help!
As I say, I know nothing about topoJSON files etc...
In effect, what I am trying to create is a dataset with the information needed to create a shape map for Barcelona, Spain, which I will then used in different PBI reports. I came across the topoJSON file (of which I posted an extract above) and thought I was in luck.
I actually followed Jimmy Tao's instructions in this thread to set up the data table:
How to import a topoJSON file to make a Shape map
In his example, the field used I see is labeled "coordinates" whereas the file I have found seems to include only "Area" and "Perimiter"; ie no coordinates.
If I use either of these in a Shape map visual, the options under Shape in the format pane are a few countries/regions etc...No sign of Spain, or anywhere within. Does that mean that we are elimited to the maps listed under Shape in the format pane?
Here is a screenshot:
and here is the visual render of the topoJOSON file as seen on github (source for the file)
Proud to be a Super User!
Paul on Linkedin.
Ignore the other thread that you mentioned. You are trying to make this way too complicated.
You do not need to know anything about TopoJSON to make this work. Please re-read my previous answer (with the following additions/clarifications).
You need two things to make shape map visualisations:
1: A topoJSON file of the place/area/shape you are going to use. If you are lucky, a nice person on the internet will already have made one that will work for your purposes. It looks to me that you already have this because you have posted a picture of it rendering correctly on GitHub. So you are halfway there (and all you had to do was search the web).
2: Some data that relates to the shape you already have (in 1: above). This is not extracted from the TopoJSON file. It is the data that you want to connect to the shape file. See my previous post's example of "Number of coffee shops in each barrio". Your data will relate to barrios of Barcelona in some way but it will not come from editing the topojson. Remove this idea from your mind.
Get the data in 2: into your powerbi file.
Drag a shapemap on to the report surface.
Add a field to the Location field well.
Use the "+ Add map" in the format section to link the shapefile in 1:
Add another field to the Color Saturation field well.
That's it.
I highly recommend that you follow the instructions here
Success! Thank you for your patience and help!!
I can't believe that it was really that simple! I guess I was wired into thinking I needed to set coordinates (Lat/Long), similar to what I have done in the past with the simple map visual.
As you say, it was as simple as adding data to the visual data bucket from another source, clicking on the "+ Add Map" option under the Shape section in the format pane, navigate to the topoJSON file and voilà! Pretty cool!
Thank you again for your time and assistance!
Proud to be a Super User!
Paul on Linkedin.
Great. I'm glad you worked it out.
One thing more - I notice the grey areas on the shape map. This means either :
a) there is no data for those areas (which is fine) or
b) powerbi can't make a link between the shape map and the data (for just the grey areas). There is some sort of hidden magic that powerbi uses to link the shapemap with the data you add. It'll use one of the fields in 'Show map keys'. Sometimes fields don't match up due to spelling or data type mismatches or errors in the shapemap file. You can fix them by editing the data or editing the topojson file. This is something to be aware of.
Thanks again. I did in fact see this when I finally created the shape map. It's just that there are some fields in the location which don't exactly match between both sources. Easily fixed.
Much appreciate it.
Proud to be a Super User!
Paul on Linkedin.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
8 | |
6 | |
6 | |
6 | |
5 |
User | Count |
---|---|
9 | |
9 | |
8 | |
6 | |
6 |