<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>article From Points into Lines in Member Articles</title>
    <link>https://community.qlik.com/t5/Member-Articles/From-Points-into-Lines/ta-p/1481413</link>
    <description>&lt;P&gt;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],...] .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178931_seq_table.png" border="0" alt="seq_table.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[shapes]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LOAD [shape_id],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;shape_id * 10000 + shape_pt_sequence as shape_seg_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GeoMakePoint(shape_pt_lat,shape_pt_lon) as shape_pt,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[shape_pt_sequence]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FROM [lib://GTFS/shapes.txt]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;left join(shapes)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;load shape_seg_id - 1 as shape_seg_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shape_pt as shape_to_pt&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Resident shapes;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178932_seq_table2.png" border="0" alt="seq_table2.png" /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178934_seq_map2.png" border="0" alt="seq_map2.png" /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another way to is to produce a line geometry instead, quicker to draw, but the width and color are per line. Note, &lt;SPAN&gt;Concat requires "group by" and an order is necessary to get the points to line up correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;geom:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;load &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Distinct shape_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'[' &amp;amp; concat(shape_pt,',',shape_pt_sequence) &amp;amp; ']' as shape_line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident shapes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;group by shape_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178933_seq_table3.png" border="0" alt="seq_table3.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178935_seq_map1.png" border="0" alt="seq_map1.png" /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Data: GTFS data from City of Columbus.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Sep 2022 15:54:42 GMT</pubDate>
    <dc:creator>Patric_Nordstrom</dc:creator>
    <dc:date>2022-09-01T15:54:42Z</dc:date>
    <item>
      <title>From Points into Lines</title>
      <link>https://community.qlik.com/t5/Member-Articles/From-Points-into-Lines/ta-p/1481413</link>
      <description>&lt;P&gt;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],...] .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178931_seq_table.png" border="0" alt="seq_table.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[shapes]:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;LOAD [shape_id],&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;shape_id * 10000 + shape_pt_sequence as shape_seg_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GeoMakePoint(shape_pt_lat,shape_pt_lon) as shape_pt,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;[shape_pt_sequence]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;FROM [lib://GTFS/shapes.txt]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;left join(shapes)&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;load shape_seg_id - 1 as shape_seg_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; shape_pt as shape_to_pt&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN&gt;Resident shapes;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178932_seq_table2.png" border="0" alt="seq_table2.png" /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178934_seq_map2.png" border="0" alt="seq_map2.png" /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another way to is to produce a line geometry instead, quicker to draw, but the width and color are per line. Note, &lt;SPAN&gt;Concat requires "group by" and an order is necessary to get the points to line up correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;geom:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;load &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Distinct shape_id,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;'[' &amp;amp; concat(shape_pt,',',shape_pt_sequence) &amp;amp; ']' as shape_line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resident shapes&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;group by shape_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178933_seq_table3.png" border="0" alt="seq_table3.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/178935_seq_map1.png" border="0" alt="seq_map1.png" /&gt;&lt;/P&gt;&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;Data: GTFS data from City of Columbus.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 15:54:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/From-Points-into-Lines/ta-p/1481413</guid>
      <dc:creator>Patric_Nordstrom</dc:creator>
      <dc:date>2022-09-01T15:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: From Points into Lines</title>
      <link>https://community.qlik.com/t5/Member-Articles/From-Points-into-Lines/tac-p/1481414#M298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fab!&amp;nbsp; I've also used the peek function to get the previous point:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; if(isnull(peek(Latitude)), Latitude, peek(Latitude)) ) as "PreviousLatitude",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(isnull(peek(Longitude)), Longitude, peek(Longitude))) as "PreviousLongitidue",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(isnull(TrackPoint),peek(TrackPoint)) as "PreviousGeoPoint"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Oct 2017 15:33:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Member-Articles/From-Points-into-Lines/tac-p/1481414#M298</guid>
      <dc:creator>Julie_Main</dc:creator>
      <dc:date>2017-10-09T15:33:31Z</dc:date>
    </item>
  </channel>
</rss>

