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 this multilinestring that has 48 NPoints. When I execute ST_PointN(line,5) it returns none. And to continue on, it returns None for everything after index:2 up to index:48. This is how my line looks:

MULTILINESTRING((-3.1642070167833 55.9269296196706,-3.16421351659546 55.9268662214904),(-3.16421351659546 55.9268662214904,-3.16421636372824 55.9268384509897),(-3.16421636372824 55.9268384509897,-3.16422182573761 55.9267851753802),(-3.16422182573761 55.9267851753802,-3.16422870102352 55.926718114886),(-3.16422870102352 55.926718114886,-3.16423309121073 55.926675293667),(-3.16423309121073 55.926675293667,-3.16423565148822 55.9266503211093),(-3.16423565148822 55.9266503211093,-3.16424103159897 55.9265978443265),(-3.16424103159897 55.9265978443265,-3.16424680776317 55.9265415044985),(-3.16424680776317 55.9265415044985,-3.16425267254583 55.9264843002995),(-3.16425267254583 55.9264843002995,-3.16425541048045 55.9264575949012),(-3.16425541048045 55.9264575949012,-3.16426111146586 55.9264019883556),(-3.16426111146586 55.9264019883556,-3.1642667032531 55.9263474469124),(-3.1642667032531 55.9263474469124,-3.16426957768543 55.9263194101362),(-3.16426957768543 55.9263194101362,-3.16427488261739 55.9262676666359),(-3.16427488261739 55.9262676666359,-3.16428009893088 55.9262167875066),(-3.16428009893088 55.9262167875066,-3.164282741107 55.9261910161221),(-3.1642875546472 55.9261440655823,-3.164282741107 55.9261910161221),(-3.1642875546472 55.9261440655823,-3.16429466890915 55.9260746741522),(-3.16429466890915 55.9260746741522,-3.16430092974527 55.9260136069079),(-3.16430092974527 55.9260136069079,-3.16430822838418 55.9259424170929),(-3.16430822838418 55.9259424170929,-3.16431547242401 55.925871759829),(-3.16431547242401 55.925871759829,-3.16431448732505 55.9258328901507),(-3.16431770120536 55.9257327846001,-3.16431547242401 55.925871759829),(-3.164339 55.925777,-3.16431770120536 55.9257327846001))

any ideas anyone what might be going wrong? Thanks in advance!

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

ST_PointN will only get points from the first linestring in a multi linestring, see doc http://postgis.net/docs/ST_PointN.html

What you should do is splitting the multi into single linestrings with ST_Dump. You can use the path that ST_Dump returns to identify the single linestring you want to get the points from.

HTH Nicklas

share|improve this answer
    
Cool, do you know if there is a way to get the WKT of the ST_dump? I can only get the binary format..I read the doc but I do not understand how it gets the ST_AsText().. Thanks! –  Antony Feb 6 '12 at 14:56
    
SELECT ST_Astext((ST_Dump(geom)).geom) ....should work –  Nicklas Avén Feb 6 '12 at 15:00
    
I am trying ST_AsText(ST_Dump(%s)) but it returns an ERROR: function st_astext(geometry_dump) does not exist on character 8 –  Antony Feb 6 '12 at 15:10
    
alright, ST_AsEWKT() did the job. Thanks for helping me out on the ST_Dump etc. –  Antony Feb 6 '12 at 16:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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