Interactive Map Spotfire
Creating custom interactive maps for TIBCO Spotfire
Have you ever wanted to create an interactive dashboard with your own custom process map? If so, then this blogpost is exactly what you're looking for!
Here at Datatonic we also specialize in data visualization tools and all of our blogpost so far have been about Tableau Software, however this time, we will be using TIBCO Spotfire.
In order to create a custom interactive map the first thing we need is the actual map image that we want to use as our background. The original image used in this tutorial shows a nuclear power plant with several modules, each of which should be clickable in our final dashboard.
To create feature shapes from our image we will use ArcGis Map, a downloadable, free to try tool that has all the functionality we need.
Upon opening ArcGis, right click the layers folder and click add Data to import the background image of our nuclear plant. Now, under the 'windows' menu in the top bar we can open the catalog and browse to our current folder. By right clicking the folder we can create a new shapefile for our image. In this case we will select 'Polygon type'.
A new layer is now added to our hierarchy. Right click the new layer and select 'edit features' and 'start editing'. We can now start drawing all the feature shapes we need on top of our map using the tools in ArcMap. The ultimate goal will be to link these features to subsets of our data so that we can integrate the map in a dashboard. To do this, we have to label the features that we create. Select each feature, right click, go to attributes and give it an Id number. Note that by right clicking the feature layer in the left menu we can choose to display the labels on top of the map if we want to keep track of everything. In the 'Symbology' tab we can also choose to display different colors for each of the labels if we want to.
Once the feature layer is finished, we can export our layers to be used in Spotfire. Right click the image layer, select Data - Export Data... Set both the extent and spatial reference options to use the original image. Export the image as .BMP format. For the feature layer, repeat the same process, making sure to export all features for the layer's source data.
The first thing we will need in addition to some data from our plant is a lookup table that will provide the link between the feature layer we just created and the actual data from our nuclear plant.
For each of the Id labels in our feature layer (as created in ArcMap) we need to have a corresponding instance label that indicates the data column it should be linked to. The linkfile could for example look like this:
Upon opening Spotfire, we import both our actual data file and our linkfile. Note that in order to be able to link the two, we need an 'instance' field for each of the rows in the data file. A possible format could look like this:
Once both files are imported, it's time to start visualizing our interactive map.
- + Add a new map chart
- + Delete all the existing layers
- + Set the Appearance Coordinate Reference system to 'None'
- Add an image layer, import the background image (.BMP file) and set the Coordinate Reference System to 'None' in the Appearance menu
- Add a feature layer using the linkfile
- Again, set the Coordinate Reference system to 'None'
- Now, under geocoding: add a new Geocoding Hierarchy and import the shapefile (.shp) we just created in ArcMap
- In the "Feature by" menu at the top, tell Spotfire that each polygon in the shapefile corresponds to one Id of the linkfile
- Next, we have to edit the column matches to link the feature layer elements to the data columns using the Id from ArcGis. To do this, add a column match between the imported shapefile and the linkfile using the "Id" field
Since we didn't specify a custom coordinate system it is possible that the feature layer and the image layer are not aligned correctly. To fix this:
- Right click the map and select the image layer
- Under the data tab: change the 'Extent Settings'
- In ArcGis: right click the image layer and go to properties - Extent
- Copy "the current settings of this layer" numbers into Spotfire and apply.
Making the map interactive:
OK, now that the map is correctly initialized we can start building a dashboard around it. However, if we want the dashboard to be interactive inside Spotfire we will want to apply a marking whenever we click one of the plant instances on the map and then update any existing graphs using only data from that selected instance. This means that we will have to apply a marking in the linkfile (which is the data file used as feature layer) and carry it over to a different data file in our analysis, namely the actual plant data.
To do this we need to add a relation between these two data tables.
- Go to Edit - Data table properties - relations - manage relations
- Create a new relation between the linkfile and the data using the "instance" column and apply it to the analysis
Now, whenever we mark something on the process map, the corresponding rows in the data table (using the "instance" match) will also be marked.
And that's it! We can now create any visualization we want using the data table, while limiting the displayed views to whatever instance was marked in the interactive map. Moreover, we could color each of the feature layers using whatever calculation we want, to display useful information about the corresponding instance.
Note that it is also possible to add multiple feature layers on top of each other. We could for example create a top layer that displays all the instances and a drill down layer below it that shows features within each of the instances. Using data functions we could then toggle specific feature layers on or off, allowing drill downs into the interactive map!