Sometimes you come into a situation where the maps provided in Einstein Analytics are not matching your requirements and you want to create your own map. Luckily you can upload your own GeoJSON files to use as maps in Einstein Analytics.
Let’s say your business is focused on the US, Canada, and Mexico and you want to see the different states or provinces in those countries when you plot your location via latitude and longitude. At the same time, you are doing business around the world but you don’t necessarily want to see the state lines in those. To make it easy for the user you want to integrate the different levels of information in only one map as shown below.
So how can we do this? At first, we need to find a GeoJSON world map as a basic map. There are plenty of good resources out there like mapstarter.com.
How to leverage mapshaper.com to merge map layers?
In the next step you simply import this GeoJSON in mapshaper.com an online tool to edit Shapefile, GeoJSON and TopoJSON formats.
At this point, the world map is not providing the required granularity. For the US and Canada, we want to see the states/province lines. Mapshaper can help us with this as it is able to merge different GeoJSON. All we need to do is to look for the GeoJSON with the correct state lines. Mapstarter can help us here again.
Prep your files
First preparation step is to get rid of the countries in the world map which we want to replace by the country maps with more detailed information
For this, we need to open the world map JSON in an editor (e.g. Sublime ) to look up the property name with we need later in mapshaper.
In this
$ filter 'NAME != "United States"'
With this simple code snippet, I can delete the USA borders from the world map. I’m going to do the same for Canada and the world map is changing accordingly by indicating the deleted/filtered countries in green.
Merge map layers
To fill in the gaps for the US and Canada we need to import new GeoJSON’s with the required level of detail. Mapshaper allows us to simply drag and drop both files on top of the canvas. In the dropdown menu on top with the down arrow I can select which map layer I want to make visible. Here I select all 3 layers, world, US_States and Canada.
Now we can check the details in the maps and verify that the layers fit in the boarders where the different maps are touching are aligned.
In the final
$ merge-layers target=canada,US-States,world force
With
Now we can import the new map in Einstein Analytics via the custom map upload and use it as we would use any of the default maps where we leverage latitude and longitude data points.
Another example with custom GeoJSON and how to create shapes from scratch can be found here.
Resources
Mapshaper http://mapshaper.org
Mapshaper command reference
https://github.com/mbloch/mapshaper/wiki/Command-Reference
GeoJSON World, US + Canada with state lines/ province lines
Salesforce custom maps video
0 Comments Leave a comment