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],...] .





    LOAD [shape_id],

    shape_id * 10000 + shape_pt_sequence as shape_seg_id,

    GeoMakePoint(shape_pt_lat,shape_pt_lon) as shape_pt,


    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;







    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.




    Distinct shape_id,

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

    Resident shapes

    group by shape_id;






    Data: GTFS data from City of Columbus.