More powerful geospatial with KeyLines and Esri ArcGIS

12th February, 2019

The ability to visualize connections on maps is a valuable technique when you’re analyzing graph data. Whether you’re investigating locations of fraud, managing IT network infrastructure or creating a crime suspect’s geo profile, geospatial information takes insight to another level.

Using Esri map tiles with KeyLines
Using Esri map tiles with KeyLines

In this blog post, we demonstrate how to integrate KeyLines with Esri’s open source esri-leaflet library to access their ArcGIS mapping platform. We’ll investigate a New York crime spree to show how easy it is to bring your geocoded connected data to life.

KeyLines and third-party mapping service providers

The KeyLines geospatial feature gives you the freedom to work with a wide range of third-party mapping service providers. This example looks at Esri. In their words:

Esri is the global market leader in geographic information system (GIS) software, location intelligence, and mapping. Today, Esri software is deployed in more than 350,000 organizations including the world’s largest cities, most national governments, and 75% of Fortune 500 companies.

ArcGIS is Esri’s comprehensive, scalable digital mapping and analytics software. To make the most commonly used pieces of the platform more accessible, they created esri-leaflet – an open source library governed by the Apache V2.0 license agreement. It’s open to any developer to use, embed, or incorporate in their apps.

If you have the right ArcGIS licence, you can use Leaflet options to access popular ArcGIS services from other applications, including KeyLines.

One way to understand the context around location data is to layer it onto an ArcGIS basemap. KeyLines works seamlessly with every basemap layer – from world imagery and streets, to topographic markups and customized cartography.

More on this later. First, let’s get familiar with our dataset.

Visualizing and styling the dataset

We’re using fictitious data containing locations and events to reflect a crime spree. Locations are stored as JSON objects, and there are latitude and longitude properties on each node.

KeyLines supports styling options to customize your data, make it more accessible and highlight important information. Here we’ve used color-coded nodes:

  • red for robberies
  • blue for vehicle sightings
  • yellow for vehicle-related events
  • green for the suspect’s known addresses
  • purple for related information
A location-based network doesn’t make sense without a map
A location-based network doesn’t make sense without a map

We can see a route between events, but it lacks context. How far apart are the event locations? Are there connections between the suspect’s known addresses and where these events took place?

Here’s where the power of maps comes in.

Integrating KeyLines and ArcGIS using esri-leaflet

Using the esri-leaflet library gives KeyLines easy access to the street, district and satellite image data we need to fully understand the connections in our crime data.

Let’s start by removing the default tile layer used by KeyLines, so we can replace it with an ArcGIS one.

chart.map().options({
 tiles: null
});

Then we’ll get the Leaflet map from the KeyLines chart once it’s loaded and add ArcGIS’ topographic basemap layer to it instead.

chart.load(data).then(chart.map().show).then(function () {
  var leafletMap = chart.map().leafletMap();
  var basemap = L.esri.basemapLayer('Topographic');
  basemap.addTo(leafletMap);
});
The topographic view adds context
The topographic view adds context

What a difference. We instantly gain a more intuitive view of the data. The locations of Suspect #1’s Home and Workplace are much more relevant now we can spot their proximity to the start and end of the crime spree.

Flexible mapping options

Geospatial mapping has already revealed insight from connections in our data. With access to multiple ArcGIS basemaps, we can extend our analysis and try alternative ways of looking at the world.

With one click, let’s remove the existing basemap and switch to a view where transport routes are more prominent to see what we can discover.

basemap.remove();
basemap = L.esri.basemapLayer(basemap2, { zIndex: 100 });
basemap.addTo(leafletMap);
Main transport routes are easier to spot
Main transport routes are easier to spot

We can go one further by adding overlays. These layers are displayed in front of basemaps and contain relevant information about specific features, in this case, highlighted street names.

var labelLayer = L.esri.basemapLayer('ImageryTransportation',
{ pane: 'tilePane', zIndex: 200 });
This overlay makes street names more prominent
This overlay makes street names more prominent

Spotting street names more easily may help us plot the suspect’s route. With overlays, you can mark up maps any way you choose.

There’s another ArcGIS service that can help us here.

Extending the power of geo analysis

Through the open source esri-leaflet library, KeyLines has access to ArcGIS Server geocoding services. This powerful tool can convert a description of a location into an actual location on a map. It means you can create and display exactly the details you need in your graph visualizations.

In our crime scenario, we want to see which police stations are located near the events. Let’s search for ‘Police Station’.

var geocodeService = L.esri.Geocoding.geocodeService();
geocodeService.geocode().within(bounds)
 .category('Police Station').run(function (error, res) {
   // Create KeyLines items using the search results
   if (res) {
     var items = [];
     res.results.forEach(function (station, index) {
       // Create a KeyLines node for each police station
       items.push({
         type: 'node',
         id: 'policeStation' + index,
         t: station.text, // Name of the station
         pos: station.latlng // Position on the map
         // ... rest of node properties
       });
     });
     chart.merge(items);
   }
 });
Geocoding services bring new data into the chart for analysis
Geocoding services bring new data into the chart for analysis

Automatically, new nodes for police precincts and departments are brought into the chart. They can be interacted with or manipulated in exactly the same way as the original nodes in our data: the power of KeyLines analysis tools now applies to them too.

Ready to try KeyLines geospatial?

Visualizing geospatial data is crucial to revealing insight hidden in your graphs. We chose to showcase how quick and easy is to integrate with the esri-leaflet library, but KeyLines works with a range of other mapping providers too.

Geospatial is just one of many key features of KeyLines. If you’re keen to learn what else we have to offer, request a free trial or get in touch.

Read more blog posts about KeyLines.