Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a PostGIS table testtin2 which is a sort of pseudo TIN consisting of a single multilinestring geometry, which I am intersecting with another table align, also a multilinestring, to generate a set of coordinates along an alignment (or alignments) via the following query...

SELECT ST_X(q1.int_pnt), ST_Y(q1.int_pnt), ST_Z(q1.int_pnt)
FROM
(SELECT ST_Intersection(align.geom, testtin2.geom) as int_pnt 
FROM align INNER JOIN testtin2 ON ST_Intersects(align.geom, testtin2.geom)
WHERE ST_isvalid(align.geom)='t' AND ST_isvalid(testtin2.geom)='t') As q1;

Which works fine except for the fact that the resulting output is seemingly in a 'random' order. Is there a way this query might be modified or re-written such that the coordinates come out in the correct linear sequence along the alignment linestring(s) from the align table?

I need this to happen so that the drafting software I am passing the coordinates to will join the dots up in the correct order.

Thanks in advance.

share|improve this question

closed as too localized by underdark Jul 18 '12 at 13:36

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
...actually I suspect it may help if I break my alignment multilinestring into linestrings either beforehand or in the query somehow but I am not sure how to do this either. –  Will Jun 18 '12 at 11:12
add comment

1 Answer

Fixed it. Recreated the align table as linestrings (as opposed to a single multilinestring record) and then used the linear referencing function ST_line_locate_point to calculate the distance of each coordinate along the line it belonged to, before ordering the results by this value.

Thanks to anyone who looked.

share|improve this answer
add comment

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