<?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 Dynamic Segmentation in Geospatial Analytics on Databricks - Part 2 in Technical Blog</title>
    <link>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/ba-p/91802</link>
    <description>&lt;P&gt;&lt;I&gt;&lt;SPAN&gt;This is the second part of a two-part series blog on geospatial data processing on Databricks. In the &lt;/SPAN&gt;&lt;/I&gt;&lt;A href="https://community.databricks.com/t5/technical-blog/from-raw-to-refined-processing-overture-maps-geospatial-data-on/ba-p/90838" target="_blank" rel="noopener"&gt;&lt;I&gt;&lt;SPAN&gt;first part&lt;/SPAN&gt;&lt;/I&gt;&lt;/A&gt;&lt;I&gt;&lt;SPAN&gt;, we covered ingesting and processing Overture Maps data on Databricks.&amp;nbsp; In this second part, we will delve into a practical use case on dynamic segmentation.&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Imagine driving down a winding road where the speed limit changes every few hundred metres, or navigating a city where the pavement conditions shift from smooth asphalt to bumpy gravel. This dynamic nature of our road networks presents a fascinating challenge for location intelligence. Dynamic segmentation is a powerful technique that allows us to slice and dice linear features based on varying attributes.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For instance, city planners might use dynamic segmentation to determine whether sections with higher curbs experience fewer pedestrian-related accidents compared to those with lower curbs, or how accident rates change in areas where the speed limit fluctuates. This granular approach to road network analysis enables city planners and traffic engineers to identify high-risk zones and implement targeted safety measures, potentially saving lives and reducing injuries.&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;While this method can be applied in a multitude of scenarios, from environmental monitoring to urban planning, this blog post will zoom in on road networks as a captivating use case.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;Understanding Dynamic Segmentation&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;Dynamic segmentation is the process of dividing linear features into segments based on changing attributes along their length. This technique is particularly useful for analysing and visualising how properties like speed limits, pavement conditions, or traffic volumes vary along a road network.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="dannywong_4-1727308411198.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/11499iF5E2A3C1F8D6B02A/image-size/large?v=v2&amp;amp;px=999" role="button" title="dannywong_4-1727308411198.png" alt="dannywong_4-1727308411198.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dynamic segmentation creates variable-length segments that accurately represent changes in attributes. This approach provides a more precise representation of real-world conditions and enables more nuanced analysis.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;Apache Sedona and Databricks: A Powerful Combination&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;The Databricks Lakehouse platform offers a powerful and flexible environment for processing geospatial data at scale, through built-in product features as well as by using various 3rd party libraries. One popular library, among many, is &lt;/SPAN&gt;&lt;A href="https://sedona.apache.org/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Apache Sedona&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;, a geospatial data processing Apache Spark-based framework. Sedona has some useful functions for the focus of this dynamic segmentation use case, which can be applied to augment our built-in capabilities.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Databricks enhances geospatial workloads with innovative features like &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/delta/clustering.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;Liquid Clustering&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;, which simplifies data layout and improves query performance; &lt;/SPAN&gt;&lt;A href="https://docs.databricks.com/en/sql/language-manual/sql-ref-h3-geospatial-functions.html" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;30+ native H3&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; global gridding functions, enabling highly scalable discrete spatial analytics; and 60+ Spatial SQL functions, currently in private preview for DBR 14.3+ (reach out to your Databricks sales team to join the preview).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Users can easily install Apache Sedona on their Databricks clusters by following straightforward&lt;/SPAN&gt;&lt;A href="https://sedona.apache.org/1.6.0/setup/databricks/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt; instructions&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;. This extensibility, combined with the platform's distributed processing power and performance optimizations, positions Databricks as an ideal choice for organizations dealing with large-scale geospatial analytics and dynamic segmentation tasks.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="dannywong_5-1727308490158.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/11500i7F2E18A50682A6EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="dannywong_5-1727308490158.png" alt="dannywong_5-1727308490158.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;Implementing Dynamic Segmentation&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;Let's explore how to perform dynamic segmentation using Apache Sedona on Databricks. We'll use a road network dataset and segment it based on different attributes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Example 1: Segmenting Roads by Pavement Condition&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;In this example, we'll segment a road network (Rte) based on pavement condition (PC):&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;LI-CODE lang="javascript"&gt;SELECT     PC.Classified_Road_Number
         , PC.Direction
         , PC.route
         , PC.Surface_Type
         , PC.Roughness_Category
         , PC.Start_Chainage_m
         , PC.End_Chainage_m
         , ST_LineSubstring(  Rte.geometry
                            , PC.Start_Chainage_m/Rte.ARCLENGTH
                            , PC.End_Chainage_m/Rte.ARCLENGTH
                            ) as geometry
FROM      pavement_condition PC, routes Rte
WHERE     PC.route = Rte.ROUTE_ID 
AND       Classified_Road_Number = 1234 &lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;In transportation planning or traffic analysis, Sedona’s &lt;/SPAN&gt;&lt;A href="https://sedona.apache.org/1.6.0/api/sql/Function/?h=st_linesubstring#st_linesubstring" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;ST_LineSubstring&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; can be used to extract a particular segment of a road or path for detailed study, such as a stretch of road where frequent accidents occur.&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;Rte.geometry&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; is the full geometry of the route.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;PC.Start_Chainage_m/Rte.ARCLENGTH&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; calculates the start point of the substring as a fraction of the total route length.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;PC.End_Chainage_m/Rte.ARCLENGTH&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; calculates the end point of the substring as a fraction of the total route length.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;For large LINESTRING geometries (e.g., routes), ST_LineSubstring can be used to create smaller, more manageable segments (e.g., Pavement conditions) for analysis. This can be particularly useful when working with large datasets or when only a specific section of the data is relevant.&lt;/SPAN&gt;&lt;/P&gt;
&lt;H2&gt;&lt;SPAN&gt;Example 2: Finding measure value along a route&lt;/SPAN&gt;&lt;/H2&gt;
&lt;P&gt;&lt;SPAN&gt;This example is to calculate the distance along a specific bus route (RTE) to each bus stop (BS) on that route.&lt;/SPAN&gt;&lt;/P&gt;
&lt;TABLE style="border-style: hidden; width: 100%;" border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;&lt;LI-CODE lang="javascript"&gt;SELECT     RTE.ROUTE_ID
         , BS.Location_Description
         , ST_LineLocatePoint(RTE.geometry, BS.geometry) * ARCLENGTH as measure
FROM     route_bus_stops BS, routes RTE
WHERE    RTE.ROUTE_ID = 1234
ORDER BY measure&lt;/LI-CODE&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;SPAN&gt;For managing transportation assets such as bus stops, signage, and maintenance points, Sedona’s &lt;/SPAN&gt;&lt;A href="https://sedona.apache.org/1.6.0/api/sql/Function/?h=st_linelocatepoint#st_linelocatepoint" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;ST_LineLocatePoint&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; can help pinpoint their exact locations on the road network. This aids in asset inventory management, maintenance scheduling, and optimising the placement of new assets.&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;ST_LineLocatePoint(RTE.geometry, BS.geometry) &lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt;returns a fraction between 0 and 1, representing where the bus stop point is located along the route line.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;This fraction is then multiplied by &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;ARCLENGTH&lt;/SPAN&gt;&lt;/FONT&gt;&lt;SPAN&gt; (the total length of the route) to convert it into an actual distance measure.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;This is a useful application of spatial analysis in transportation planning. It can help in:&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Visualising the distribution of bus stops along a route&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Calculating distances between consecutive stops&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI style="font-weight: 400;" aria-level="1"&gt;&lt;SPAN&gt;Analysing the coverage and accessibility of public transport along the route&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;H1&gt;&lt;SPAN&gt;Benefits of Dynamic Segmentation on Databricks&lt;/SPAN&gt;&lt;/H1&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN&gt;Scalability: Efficiently process large road networks with the distributed computing environment, while Delta Lake ensures high performance, transactional reliability, and governance.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Flexibility: Easily adapt dynamic segmentation to various attributes or conditions, with Liquid Clustering enabling data layout evolution without rewrites.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Integration: Results can be seamlessly integrated with other data analysis workflows on the Databricks Platform to combine the power of spatial and aspatial data on a single unified platform.&lt;/SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="dannywong_6-1727308785610.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/11501iC8309A6C3384B873/image-size/large?v=v2&amp;amp;px=999" role="button" title="dannywong_6-1727308785610.png" alt="dannywong_6-1727308785610.png" /&gt;&lt;/span&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;Visualisation: Visualize segmented data using popular GIS tools or directly within Databricks Notebooks using open source libraries like &lt;/SPAN&gt;&lt;A href="http://kepler.gl" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;kepler.gl&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="dannywong_8-1727308855863.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/11503i0AD8EA083F826E0C/image-size/large?v=v2&amp;amp;px=999" role="button" title="dannywong_8-1727308855863.png" alt="dannywong_8-1727308855863.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;&lt;SPAN&gt;Conclusion&lt;/SPAN&gt;&lt;/H1&gt;
&lt;P&gt;&lt;SPAN&gt;Dynamic segmentation opens up a world of possibilities in location intelligence, transforming how we understand and interact with our road networks. By leveraging Apache Sedona on Databricks, we can slice through complex data to reveal insights about speed limits, pavement conditions, and bus stop locations.&amp;nbsp; Buckle up and get ready to uncover the hidden narratives in your datasets!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you haven't already, make sure to check out the &lt;/SPAN&gt;&lt;A href="https://community.databricks.com/t5/technical-blog/from-raw-to-refined-processing-overture-maps-geospatial-data-on/ba-p/90838" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;first part of our series&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;, where we discussed the foundational steps of processing Overture Maps data on Databricks. Together, these two-part series give you a couple of practical examples of running geospatial workloads on Databricks.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 21 Oct 2024 22:34:37 GMT</pubDate>
    <dc:creator>dannywong</dc:creator>
    <dc:date>2024-10-21T22:34:37Z</dc:date>
    <item>
      <title>Dynamic Segmentation in Geospatial Analytics on Databricks - Part 2</title>
      <link>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/ba-p/91802</link>
      <description>&lt;P&gt;&lt;I&gt;&lt;SPAN&gt;This is the second part of a two-part series blog on geospatial data processing on Databricks. In the &lt;/SPAN&gt;&lt;/I&gt;&lt;A href="https://community.databricks.com/t5/technical-blog/from-raw-to-refined-processing-overture-maps-geospatial-data-on/ba-p/90838"&gt;&lt;I&gt;&lt;SPAN&gt;first part&lt;/SPAN&gt;&lt;/I&gt;&lt;/A&gt;&lt;I&gt;&lt;SPAN&gt;, we covered ingesting and processing Overture Maps data on Databricks.&amp;nbsp; In this second part, we will delve into a practical use case on dynamic segmentation.&lt;/SPAN&gt;&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 22:34:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/ba-p/91802</guid>
      <dc:creator>dannywong</dc:creator>
      <dc:date>2024-10-21T22:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Segmentation in Geospatial Analytics on Databricks - Part 2</title>
      <link>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/bc-p/92804#M299</link>
      <description>&lt;P&gt;Nice work Danny, just curious where the speed zone stuff is, example 1 appears to be pavement condition data?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 22:17:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/bc-p/92804#M299</guid>
      <dc:creator>robert_potter</dc:creator>
      <dc:date>2024-10-04T22:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Segmentation in Geospatial Analytics on Databricks - Part 2</title>
      <link>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/bc-p/92875#M301</link>
      <description>&lt;P&gt;My bad, thanks for spotting that Rob and I will make the change!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 02:05:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/technical-blog/dynamic-segmentation-in-geospatial-analytics-on-databricks-part/bc-p/92875#M301</guid>
      <dc:creator>dannywong</dc:creator>
      <dc:date>2024-10-07T02:05:14Z</dc:date>
    </item>
  </channel>
</rss>

