This guide describes how the Connect with Lines analysis joins points into lines, based on user input. The commuter flow map above uses US Census Journey to Work data, connect with lines enables you to build visualizations from your point data to visualize underlying connections between points.
The data suitable for this analysis can come in many forms, but the input must be a set of points. CARTO Builder has multiple types of options for connecting points into lines:
To Source: Connect two point columns, in two different tables, based on an optional matching condition, and apply it to both the target and the source tables.
To Column: Connect two unique columns of geo-located points in a single dataset. For example, this is useful when you have pick-up and drop-off locations for taxi data, and want to visualize (or query) the distances through line geometries.
Sequential: Sequentially join points, subject to optional conditions: grouping by a category and ordering by a value. For example, animal movement data or GPX data. You can visualize the movement as a track, grouping by species, and ordering by time.
To Single Point: Join all points in your dataset to a single point, by defining the location attributes (latitude and longitude) of a focus point. This is useful when connecting multiple points to a single point of interest. For example, if you want to visualize the route from a distribution center to all of its delivery locations.
For example, this dashboard displays how the Connect with lines analysis was used to display the Colorado County to County Commuter Flow.
For this guide, let's use the Connect with lines analysis to visualize the most popular Google Flight Search destination (and its origins for Thanksgiving) with data provided from The New York Times' Upshot.
To visualize flight data, download the template .carto file and import it to your account. Builder opens with flight destination as the first map layer and origin cities as the second map layer.
Select the Origin City map layer.
Click the ANALYSIS tab.
Click Connect with lines and apply the following options to indicate Miami, FL as the point of origin:
The result displays the crow-flight distance between the airports, from the origin cities to the destination.
Click the DATA tab and select Add as a widget for the
weight column and the
weight column defines the ratio of flight searches during Thanksgiving week, compared to an ordinary week of the year.
length output column was created as a result of the Connect with lines analysis, and displays the distance between the airports from the origin cities to the destination.
Click and drag the original source of data from a map layer to create a new layer.
From the LAYERS pane in Builder, click on the original source file (origin_cities) from layer B.
Drag it above layer B.
A new layer (layer C) is created and displays the end points of the destination on your visualization.
If you are interested in using the underlying functions in the SQL view of Builder, view the PostGIS documentation for
ST_MakeLine. All analyses in Connect with Lines use various forms of the
We would love to hear from you! Was it easy to understand? Do you need more information? Let us know.