Understanding TopoJSON & it's usage within vega

514 views
Skip to first unread message

knomdlo

unread,
Sep 7, 2017, 4:17:50 AM9/7/17
to vega-js
Hi,

I have a requirement very similar to unemployment example except for I need to apply this to the world map.

I have no knowledge on GeoJSON or TopoJSON structures used to design these maps.

I noticed that each of the section(country in my req.) has been assigned an ID & I can refer to the shape with ID.
I did that with world map example with a junk data (countryrate.json attached) & am able to get the desired view.




But I need more interactions on country level. 

Can someone help me in how the ID's to these country shapes are assigned. 
The JSON I have to transform  contains country names & a rate. What's the best approach to map these country names to ids on the maps.

Also can any references to links/examples that can help understand maps design in charts would help me.

Thanks in advance.

countryrate.json
world.json
worldData.json

Roy I

unread,
Sep 9, 2017, 9:45:34 AM9/9/17
to vega-js
The topojson file "world-100m.json" in Vega 3.0 map examples is from this source:

The field "id" in this topojson file is the ISO 3166-1 three-digit numeric code for country or area (same as the United Nations M49 code): 

To create the choropleth map with shaded country polygons, your input data will need to include a field with this numeric country code, or else create a derived field with this code using Vega 3.0 transforms ("formula" and "lookup") using additional input datasets.  

If your input dataset uses a field with custom country names to identify data for each country, you will probably need a separate dataset for lookup of ISO/M49 country codes for your custom country names. 

To include other country attributes, include additional input dataset(s) for Vega 3.0 transform "lookup" to create all the fields you need (e.g. country/area name, population, etc.)

Notes: 
1. The topojson "id" field is numeric (e.g. 40) whereas the ISO/M49 country code is usually formatted as zero-padded 3-digit string (e.g. "040"). Keep this in mind when using the topojson "id" field in Vega 3 -- especially when used with transform "lookup".

2. The topojson "id" field may have values (such as -99 for Somaliland) with no corresponding ISO/M49 code. These can cause unexpected results in the choropleth map.    See Somaliland:
Reply all
Reply to author
Forward
0 new messages