Package: homogeneous-segmentation
homogeneous-segmentationMethods for homogenous segmentation of linear spatial data, such as pavement
performance indicators and traffic volumes.This python package contains two of the three segmentation methods ported from theR package named HS.1. Introduction1.1. Aim1.2. Background1.3. Relevance for Austroads Pavement Design2. Installation3. Usage4. See Also1. IntroductionThis python package has been ported from anR package - also called HS.
The author of the original R package is Yongze Song and theHSpackage is related to
the following paper:Song, Yongze, Peng Wu, Daniel Gilmore, and Qindong Li.
"A spatial heterogeneity-based segmentation model for analyzing road deterioration network data in multi-scale infrastructure systems."
IEEE Transactions on Intelligent Transportation Systems (2020).This project is not a complete port of the original R version;
Only the following two methods have been ported:Segmentation usingSpatial Heterogeneity Segmentation (SHS)Segmentation usingMinimize Coefficient of Variation (MCV)The following is not implementedSegmentation using theCumulative Difference Approach (CDA)1.1. AimThe aim of this package is to help break apart and group road segments based on
one or more road condition variables such that each segment can be reasonably
represented by a single characteristic value.Note: I am not yet convinced that existing methods can do a good job of
segmentation when basing the segmentation on multiple variables.
Although the functions in this package do accept multiple condition
variables, they do not for example, support strategies such asWeighting each variable based on importance to the segmentationSegmenting first by each variable independently then combining
segmentations, etc.1.2. BackgroundSegmentation refers to the spatial-linear indexing of road data to the physical
road network. Sometimes data is available at constant interval length (e.g.
every 10 metres for roughness), and must be grouped into larger intervals.
Sometimes data has uneven intervals (eg local government area) and must be split
and regrouped.1.3. Relevance for Austroads Pavement DesignAustroads "Guide to Pavement Technology Part 5: Pavement Evaluation and
Treatment Design"AGPT05-19section9.2.5 Selection of Homogeneous SectionsrecommendsHomogenous Sections should be longer than 100 metresHomogenous Sections should have a coefficient of variation (standard deviation
divided by the mean) no greater than 0.25 to be considered homogeneousAGPT05-19 Section 9.2.5recommends the use of the cumulative difference
approach outlined inAppendix Dof the same document to identify Homogeneous
Sections for the design of pavement overlays.The paper cited above describes theCumulative Difference Approach (CDA)and
its limitations, and compares its output to theMCVandSHSalgorithms.2. Installationpipinstallhomogeneous-segmentation3. UsageThe following example shows how to use the thesegment_ids_to_maximize_spatial_heterogeneity()andsegment_ids_to_minimize_coefficient_of_variation()methods;Note: that in this example theSHSandMCVmethods produce the same
output. This is not always the case, but seems to be fairly typical for small
sections of data. I had trouble finding a section of data to demonstrate the
difference in outputs.fromhomogeneous_segmentationimport(segment_ids_to_maximize_spatial_heterogeneity,segment_ids_to_minimize_coefficient_of_variation)importpandasaspdfromioimportStringIOdf=pd.read_csv(StringIO("""road,slk_from,slk_to,cwy,deflection,dirnH001,0.00,0.01,L,179.37,LH001,0.01,0.02,L,177.12,LH001,0.02,0.03,L,179.06,LH001,0.03,0.04,L,212.65,LH001,0.04,0.05,L,175.35,LH001,0.05,0.06,L,188.66,LH001,0.06,0.07,L,188.31,LH001,0.07,0.08,L,174.48,LH001,0.08,0.09,L,210.28,LH001,0.09,0.10,L,260.05,LH001,0.10,0.11,L,228.83,LH001,0.11,0.12,L,226.33,LH001,0.12,0.13,L,245.53,LH001,0.13,0.14,L,315.77,LH001,0.14,0.15,L,373.86,LH001,0.15,0.16,L,333.56,L"""))df["seg.shs"]=segment_ids_to_maximize_spatial_heterogeneity(data=df,measure=("slk_from","slk_to"),variable_column_names=["deflection"],allowed_segment_length_range=(0.030,0.080))df["seg.mcv"]=segment_ids_to_minimize_coefficient_of_variation(data=df,measure=("slk_from","slk_to"),variable_column_names=["deflection"],allowed_segment_length_range=(0.030,0.080))expected_result=pd.read_csv(StringIO("""road,slk_from,slk_to,cwy,deflection,dirn,seg.shs,seg.mcvH001,0.00,0.01,L,179.37,L,1,1H001,0.01,0.02,L,177.12,L,1,1H001,0.02,0.03,L,179.06,L,1,1H001,0.03,0.04,L,212.65,L,1,1H001,0.04,0.05,L,175.35,L,2,2H001,0.05,0.06,L,188.66,L,2,2H001,0.06,0.07,L,188.31,L,2,2H001,0.07,0.08,L,174.48,L,2,2H001,0.08,0.09,L,210.28,L,2,2H001,0.09,0.10,L,260.05,L,3,3H001,0.10,0.11,L,228.83,L,3,3H001,0.11,0.12,L,226.33,L,3,3H001,0.12,0.13,L,245.53,L,3,3H001,0.13,0.14,L,315.77,L,3,3H001,0.14,0.15,L,373.86,L,3,3H001,0.15,0.16,L,333.56,L,3,3"""))# check the result matches the expected resultpd.testing.assert_frame_equal(left=df,right=expected_result,check_like=True# ignore column and row order)4. See AlsoSee the python packagehttps://github.com/thehappycheese/segmenterfor further
methods to help with road segments, including tools to break longer segments
into shorter ones. At the time of writing segmenter has not yet been published
to PyPI