Qlik Community

Qlik GeoAnalytics Documents

Documents related to Qlik GeoAnalytics.

From Points into Lines

Employee
Employee

From Points into Lines

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)
Attachments
Comments
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
Revision #:
1 of 1
Last update:
‎10-07-2017 10:24 AM
Updated by: