By default Vitara map chart can show US map and World Countries. But we can also draw any other country’s map. Let’s consider a simple example of creating a map for Countries of the United Kingdom by population. The data file i have is:
The first step is, to download the shapefile (.geo.json file) which suits with our data. As the data i have is at country level, i have to search for shapefile of the United Kingdom at country level (admin-0 level).
The reference web page to download GeoJSON shape-files: http://code.highcharts.com/mapdata/
The following is the geojson file which we need for our example.
Click on GeoJSON file type to downloaded the file. We have to check the downloaded GeoJSON file, whether it contains the same coordinates which we want. For this purpose, use any online json viewers, for example: http://jsonviewer.stack.hu/
Open the downloaded GeoJSON file using any text editor, for example notepad. Copy the entire text and paste in json viewer web page.
Now click on ‘Viewer’ tab beside the ‘Text’ tab.
Now the geojson content will be displayed in json tree structure.
In JSON tree structure, one of the object is ‘features’ array. If we expand ‘features’ array we will have the objects for each partition of the chart. In our United Kingdom countries example, as there are four partitions in the chart representing each country (England, Scotland, Wales and Northern Ireland) so there are objects named from 0 to 3.
Now it is clear that the shape we downloaded is what we require. Our data and the shapefile coordinates are perfectly matching.
The next step is, we have to identify the ‘dictionary key’. Dictionary key is the parameter by which each partition in the shape file is identified uniquely. The united Kingdom map has four partitions, and these partitions should be identified with some boundary coordinated. Each of these boundary coordinates are given one unique name. These unique names are mentioned in the ‘properties’ field of each partition of GeoJSON file. To know dictionary key expand any object, for example ‘0’ and expand ‘properties’ array.
Please see the rounded area in the below screenshot.
In this properties array there are several fields which can be used as dictionary key. For example, we can use ‘hc-a2’ field as dictionary key. For England hc-a2 field value is ‘EN’, for Wales it is ‘WA’, for Scotland it is ‘SC’ and for Northern Ireland it is ‘NI’. You may notice that all the fields are unique.
Here the point is you can define any field as dictionary key but it should match with our data. In our data file we have country names rather than short forms.
Therefore, exact matching fields in the properties array with our data is the ‘name’ field.
In case if we don’t find any matching dictionary key field in shapefile with data file, we have to create the synonyms. This is explained in the section ‘Dictionary property’ in the documet titled ‘Customization of the Map chart’.
After identifying dictionary key we can define a new map layer for our example. For this edit ‘mappinglayers.txt’ file, which will be in the following path in Vitara map chart installation folder.
C:\Program Files\Apache Software Foundation\Tomcat 8.0\webapps\MicroStrategy \plugins\VitaraMaps\custom
The following is the screenshot of ‘mappingLayers.txt’ file. There are three predefined mapping layers, world physical, US physical, and US Countries.
The following is the notation to add new map layer: <ns>.<property>
<ns>: NameSpace, this can be any combination of alphabets, but choose a unique value for each new map layer. The map layer should contain the following properties;
In the ‘name’ property we define the name of the map we want to give.
For example, i want to give ‘United Kingdom’ as the name, then ‘name’ property definition will be
kk.name= United Kingdom
In the shape property definition we should give the path where we copied the shape file of our map. For our example, as we copied the shape file into VitaraMaps\custom\shapes folder, the following is the shape property definition.
All the shape files should be placed in ‘Shapes’ folder in custom folder. This is not compulsory, but in the naming convention point of view it’s better to do.
Dictionary key property definition will be the unique identity field we selected in GeoJSON shapefile.
kk.dictionarykey = name
In the mapping layers text file start a new map definition and define name, shape, dictionary key properties.
(please refer section ‘Mapping layers text file‘ in the document titled ‘Customization of the Map chart’for more information about ‘mapping layers text file)
kk.name= United Kingdom
Please refer the sections ‘Name’ property, ‘Shape’ property, ‘Dictionary key’ property and Dictionary’ property in the document titled ‘Customization of the Map chart’ to know the procedure how to define these properties. After defining all these properties save ‘Mapping layers’ text file.
The following is the screenshot of mappingLayes.txt file after defining United Kingdom mapping layer.
Now create a dossier or RS document in MicroStrategy and apply Vitara map chart. By default vitara map will display ‘World Physical’ map. Click on ‘edit’ button, and select ‘map’ tab. Expand the ‘Map Layer’ drop down button. Here you will find the new map definition ‘United Kingdom’. Select this map layer. Please refer the below screenshot.
Apply required Map attribute and a metric to the visualization.