PostGIS: From Multilinestring to Linestring

Continuing on with my PostGIS tinkering, I’ve been further exploring getting data in and out of PostGIS. After recompiling GEOS to get the C API working so that I could start working with the new features in PostGIS 1.2.1.

One of the problems I ran in to is that gpx2shp really likes to import data as a Multilinestring, while in the simplest case of a single-track GPX file, it should really be a Linestring. After searching a bit, I came across a mention of linemerge which can turn a Multilinestring such as MULTILINESTRING((-95.235071 38.971896,-95.235076 38.971906,-95.235015 38.971848)) in to a LINESTRING(-95.235071 38.971896,-95.235076 38.971906,-95.235015 38.971848), which seems like a saner way to work with single tracks.

1 Response to “PostGIS: From Multilinestring to Linestring”


  1. 1 Darian Buhro Jun 14th, 2007 at 4:11 am

    This one makes sence “One’s first step in wisdom is to kuesstion everything - and one’s last is to come to terms with everything.”

Leave a Reply