Skip to main content

Member Articles

This forum is for user/member-created articles across the entire Qlik portfolio. Any member that is logged in can create and publish an article here. You must choose the appropriate label in order for the articles to be properly categorized.

Announcements
NEW webinar Dec. 7th: 2023 Outlook, A Pivotal Year for Data Integration SIGN ME UP!

From Points into Lines

cancel
Showing results for 
Search instead for 
Did you mean: 
Patric_Nordstrom
Employee
Employee

From Points into Lines

Attachments

Sometimes we get a table with sequential points that we want to visualize as lines. In Qlik GeoAnalytics lines are specified as start and end point (coordinate or location) or as a line geometry [[long1,lat1],[long2,lat2],...] .

 

seq_table.png

 

[shapes]:

LOAD [shape_id],

shape_id * 10000 + shape_pt_sequence as shape_seg_id,

GeoMakePoint(shape_pt_lat,shape_pt_lon) as shape_pt,

[shape_pt_sequence]

FROM [lib://GTFS/shapes.txt]

 

One way is copy the next point as an end point to each line, perhaps by loading the point table again. This produces line segments that can have individual color and width, the downside that's it heavier to render.

 

left join(shapes)

load shape_seg_id - 1 as shape_seg_id,

    shape_pt as shape_to_pt

Resident shapes;

 

seq_table2.png

 

seq_map2.png

 

 

Another way to is to produce a line geometry instead, quicker to draw, but the width and color are per line. Note, Concat requires "group by" and an order is necessary to get the points to line up correctly.

 

geom:

load

Distinct shape_id,

'[' & concat(shape_pt,',',shape_pt_sequence) & ']' as shape_line

Resident shapes

group by shape_id;

 

seq_table3.png

 

seq_map1.png

 

Data: GTFS data from City of Columbus.

 

Labels (1)
Comments
Julie_Main
Employee
Employee

Fab!  I've also used the peek function to get the previous point:

if(isnull(peek(Latitude)), Latitude, peek(Latitude)) ) as "PreviousLatitude",

  if(isnull(peek(Longitude)), Longitude, peek(Longitude))) as "PreviousLongitidue",

    if(isnull(TrackPoint),peek(TrackPoint)) as "PreviousGeoPoint"

Version history
Last update:
‎2022-09-01 11:54 AM
Updated by: