1

My test scenario is to confirm the image below, I select the points on the line in order of the direction the line was drawn.

Order points

I used the sql:

    Select
  testepoint."id" 
FROM
    testepoint
inner JOIN
    teste
ON
  ST_DWithin(teste.geom, testepoint.geom, 1) 
WHERE
    teste."id"= 1 
ORDER BY
  ST_Line_Locate_Point(teste.geom, testepoint.geom) 

I placed the order by to sort the way I want, as the line was drawn

    ORDER BY
  ST_Line_Locate_Point(teste.geom, testepoint.geom) 

And the error occurs:

 

 ERROR: line_locate_point: 1st arg is not a line

This was because my geometry is a MultiLineString. How can I do this sort of which is a MultiLineString?

3

You may have some luck if you try passing your MultiLineString through "ST_LineMerge", depending on the actual geometry of your line. Try replacing:

ST_Line_Locate_Point(teste.geom, testepoint.geom) 

with

ST_Line_Locate_Point(ST_LineMerge(teste.geom), testepoint.geom) )

If this doesn't work then your geometry is not convertible to a single linestring. You'll need to fix the MultiLineString and make sure it's all joined up correctly.

  • Thank you! It worked exactly as I wanted. You conehce a plugin so I can store the sqls ready so users can only run without change? Conehce or any article or example of developing a plugin for this purpose? – csf May 8 '14 at 14:09

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.