Skip to main content
Question

Create an average/mean line from points

  • August 9, 2019
  • 11 replies
  • 259 views

parashari
Forum|alt.badge.img+2

I don't know if this is already answered somewhere already but couldn't find it.

This is in regards to my previous thread about aligning randomly distributed line geometry as per building footprints. Now, I could find GPS traces as point data to align my line geometry as per the points.

In the image below: The black line is the approximate required solution

I tried using NeighbourFinder with 3m distance and then MeasureSetter for putting weights. Ideally, I wanted that points towards the center are weighted more than the outer ones. I have attached some sample data for the same.

Could someone help me out with any ideas?

Thanks.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

11 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • August 12, 2019

I would try using the HullReplacer to create a polygon, followed by the CenterlineReplacer.

Hope this gets you going in the right direction.


jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • August 12, 2019

Erik's solution is reasonably simple and will give results, however outliers will have a considerable effect on the output.

Mathematically speaking what you want is LOESS (locally estimated scatterplot smoothing) or non-linear regression. In FME this is probably best achieved using the RCaller.


virtualcitymatt
Celebrity
Forum|alt.badge.img+47
  • Celebrity
  • 2000 replies
  • August 13, 2019

I would also suggest to try a binning approach. Create a grid over the points, find out which grid elements have the most points. Calculate the average x, y for each bin and use the average x, y to replace bin.

 

 

Here you can take the bin which contains the most points for each row per column and for each column per row. To make the process a little better you could process this as sub-tiles.

parashari
Forum|alt.badge.img+2
  • Author
  • 132 replies
  • August 14, 2019

I would try using the HullReplacer to create a polygon, followed by the CenterlineReplacer.

Hope this gets you going in the right direction.

Thanks @erik_jan for your suggestion. I used HullAccumulator and CenterLineReplacer (approximate) and got the below output. I'll now try smoothening the polygon (from HullAccumulator) or the line (from CenterLineReplacer).

Below is what I've got. Yellow is the input and red is the output.

Also, as mentioned in my previous thread, I will now shift the road geometry that overlaps with the building footprints.

Thanks!


parashari
Forum|alt.badge.img+2
  • Author
  • 132 replies
  • August 14, 2019

Erik's solution is reasonably simple and will give results, however outliers will have a considerable effect on the output.

Mathematically speaking what you want is LOESS (locally estimated scatterplot smoothing) or non-linear regression. In FME this is probably best achieved using the RCaller.

@jdh I can assume that now from the below output, I might face issues related to:

- most importantly, smoothening the roads and reduce the number of vertices as you've mentioned. Generalizer should give me some good results.

- snapping the start and end vertex to further connecting roads, since you see the start and end vertex is going out from the road center, which is quite logical also.

- snapping the line in itself if it breaks by itself due to lack of points in between.

 

I will try understanding more RCaller and how it can smooth roads. Or should I smooth polygon first and take out the centerline in the end.

Thanks


Forum|alt.badge.img+2
  • 1891 replies
  • August 19, 2019

@hellblazer do you have a sample of the original points you can share - or send to me directly mark @ safe.com


parashari
Forum|alt.badge.img+2
  • Author
  • 132 replies
  • August 20, 2019

@hellblazer do you have a sample of the original points you can share - or send to me directly mark @ safe.com

@markatsafe I have sent you the mail.

Thanks.


Forum|alt.badge.img+2
  • 1891 replies
  • August 22, 2019

Erik's solution is reasonably simple and will give results, however outliers will have a considerable effect on the output.

Mathematically speaking what you want is LOESS (locally estimated scatterplot smoothing) or non-linear regression. In FME this is probably best achieved using the RCaller.

@hellblazer @jdh LOESS is a function of x, and is great for scatter plots and time series where f(x) increases steadily but it doesn't seem to work very well for location data. There are similar non-parametric methods - i.e. Principal Curve method. There seems to be loads of different variants. I tried a couple of the R functions, principal_curve() from the princurve library, and also the lcp() from the LPCM library. The latter holds most promise but you'd need to play around with many of the parameters. I've attached a workspace with a couple of examples. lpcmprincipalcurveexample.fmw


kimo
Contributor
Forum|alt.badge.img+10
  • Contributor
  • 96 replies
  • August 22, 2019

I found a simple R script that uses inverse distance weighting to find the best line from a group of lines. I adapted it to run in FME using an RCaller. (you need to install R and set the path in Options) average_tracks_with_R.fmwt

# average tracks is an R script to make an "average" track of several GPS

 

# tracks by combining/merging them into a "line of best fit". Made by

 

# Michiel Faber <http://www.openstreetmap.org/user/Michiel%20Faber>

 

# This software is dedicated to the public domain through CC0:

 

# http://creativecommons.org/publicdomain/zero/1.0/

 

#

 

# See http://wiki.openstreetmap.org/wiki/average_tracks for usage instructions.

 

# Home: https://github.com/dittaeva/average-tracks

 

# version: 0.5

 

# date: 2014-01-02

 

 

# 15 Aug 2018 kimo

 

# skip loading csv records, done by FME

 

# load frame "tracks" has columns lat, lon, routeID

parashari
Forum|alt.badge.img+2
  • Author
  • 132 replies
  • August 28, 2019

I found a simple R script that uses inverse distance weighting to find the best line from a group of lines. I adapted it to run in FME using an RCaller. (you need to install R and set the path in Options) average_tracks_with_R.fmwt

# average tracks is an R script to make an "average" track of several GPS

 

# tracks by combining/merging them into a "line of best fit". Made by

 

# Michiel Faber <http://www.openstreetmap.org/user/Michiel%20Faber>

 

# This software is dedicated to the public domain through CC0:

 

# http://creativecommons.org/publicdomain/zero/1.0/

 

#

 

# See http://wiki.openstreetmap.org/wiki/average_tracks for usage instructions.

 

# Home: https://github.com/dittaeva/average-tracks

 

# version: 0.5

 

# date: 2014-01-02

 

 

# 15 Aug 2018 kimo

 

# skip loading csv records, done by FME

 

# load frame "tracks" has columns lat, lon, routeID

Hi, @kimo Thanks a lot for your suggestion.

I am still working on your idea as we have millions of GPS lines which I am trying to work upon, which create thousands of csv files. I will get back to you on this as soon as I do this! Thanks.


Forum|alt.badge.img+2
  • 1891 replies
  • November 10, 2021

Example workspace attached