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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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