[postgis-users] Sorting/ordering linestrings

fork forkandwait at gmail.com
Wed Mar 30 15:15:30 PDT 2011

Charles Galpin <cgalpin <at> lhsw.com> writes:

> Does anyone have any bright ideas on how to sort linestrings (with postgis 
>or  anything else for that matter).

You could sort them based on their beginning and ending lat's and long's, and
then connect them if they are within a certain tolerance, probably using 
a loop.  

You might also want to make a distance matrix and iteratively merge "close
enough" linestrings.

However, if you can give us some specifics about your problem (schemas, 
typical geometries and attributes) we might come up with something more
 useful and less hand-wavy.

> Thanks,
> charles

More information about the postgis-users mailing list