1

I don't have tools like ArcGIS. I have two LINESTRINGs

LINESTRING(121.5160996 25.0358556,121.5168148 25.0347768,121.5170452 25.0345573)

LINESTRING(121.517053 25.0345682,121.516851 25.0347814,121.5161259 25.0358884)

They are the same MRT route with different directions. Is there any algorithm or module that can merge them to one LINESTRING like the red one in picture?

enter image description here enter image description here

1 Answer 1

1

Is there any algorithm or module that can merge them to one LINESTRING like the red one in picture?

If you are only interested in the algorithm to do this, you can compute medial axis from computational geometry, using functions such as ST_ApproximateMedialAxis.

More specifically, you can

  1. construct a polygon from the two parallel LINESTRINGs e.g. by concatenating the WKT coordinates in an appropriate order, and
  2. find its medial axis. See the example from PostGIS documentation below.

    enter image description here

The function is available from the CGAL library, which has bindings/interfaces to various languages and tools including GIS tools like PostGIS.

1
  • 1
    the link is broken
    – Ian Turton
    Jun 6, 2017 at 10:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.