<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">Ok,<br></div><div class="gmail_default" style="font-family:monospace,monospace">let's do some tweaking then.<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">I did something very similar, but my code is more complex that it should because I did it considering the fuzziness of the data<br>, so I don't think it will be of much help.<br><br></div><div class="gmail_default" style="font-family:monospace,monospace">I tried 2 methods : <br></div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">Filtering using surface erosion<br></div><div class="gmail_default" style="font-family:monospace,monospace"> - starting from a surface (called Surf)<br>  * generate an erosion of Surf (buffer with negative radius) called SurfEroded, so that you get SurfEroded close to the centerline<br></div><div class="gmail_default" style="font-family:monospace,monospace">  * compute Straight skeleton of Surf , called SurfSS<br></div><div class="gmail_default" style="font-family:monospace,monospace">  * Simplify SurfSS to reduce the number of node, according to the precision of output you expects. This is called SurfSSS<br></div><div class="gmail_default" style="font-family:monospace,monospace">  * Dump SurfSSS into individual polylines, called SSS_seg<a href="https://github.com/Remi-C/PPPP_utilities/blob/master/postgis/rc_DumpSegments.sql"></a></div><div class="gmail_default" style="font-family:monospace,monospace">  * filter SSS_seg by removing all seg that have a node that is outside SurfEroded (and maybe that are below a given length).<br></div><div class="gmail_default" style="font-family:monospace,monospace">  * reconstruct a line from the remaining segs.<br> <br></div><div class="gmail_default" style="font-family:monospace,monospace">Filtering using end of segment isolation <br><div class="gmail_default" style="font-family:monospace,monospace"> - starting from a surface (called Surf) <br></div><div class="gmail_default" style="font-family:monospace,monospace">  * compute Straight skeleton of Surf , called SurfSS<br></div><div class="gmail_default" style="font-family:monospace,monospace">  * Simplify SurfSS to reduce the number of node, according to the precision of output you expects. This is called SurfSSS<br></div><div class="gmail_default" style="font-family:monospace,monospace">  * Dump SurfSSS into individual polylines, called SSS_seg</div><div class="gmail_default" style="font-family:monospace,monospace">  * filter SSS_seg by removing all seg that have a node that is not shared by any other segments<br></div>  * reconstruct a line from the remaining segs.</div><div class="gmail_default" style="font-family:monospace,monospace"><br><br>Cheers,<br></div><div class="gmail_default" style="font-family:monospace,monospace">Rémi-C<br></div><div class="gmail_default" style="font-family:monospace,monospace"><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-06-09 8:56 GMT+02:00 Hugues François <span dir="ltr"><<a href="mailto:hugues.francois@irstea.fr" target="_blank">hugues.francois@irstea.fr</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" link="blue" vlink="purple" lang="FR"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB">Hello,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB">I think ST_Dump could help to deal with multilinestrings: <a href="http://postgis.net/docs/ST_Dump.html" target="_blank">http://postgis.net/docs/ST_Dump.html</a><u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB">Hugues.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" lang="EN-GB"><u></u> <u></u></span></p><div><div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext">De :</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:windowtext"> <a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a> [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank">postgis-users-bounces@lists.osgeo.org</a>] <b>De la part de</b> toni hernández<br><b>Envoyé :</b> mardi 9 juin 2015 08:09<br><b>À :</b> <a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br><b>Objet :</b> Re: [postgis-users] Get only the main river. Smoothline???<u></u><u></u></span></p></div></div><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Arial","sans-serif"">Thanks Remi,<br><br>I thought that but I have no starting/ending points. St_StartPoint and St_EndPoint are not working with MultiLinestrings<br>I'll give it some more intense thought. :)<br><br>Cheers.</span><u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:8.5pt">Toni Hernández Vallès</span></b><span style="font-size:8.5pt"> <br>Servei de Sistemes d'Informació Geogràfica i Teledetecció<br>-<br>Universitat de Girona<br><b>SIGTE</b><br>-<br>Pl. Ferrater Mora 1<br>17071 Girona<br>Tel +34 972 418 039 (7026 intern)<br><a href="mailto:toni@sigte.udg.edu" target="_blank">toni@sigte.udg.edu</a> <br><br><a href="http://www.sigte.udg.edu" target="_blank">http://www.sigte.udg.edu</a><br>Twitter <a href="http://twitter.com/SIGTE_UDG" target="_blank">http://twitter.com/SIGTE_UDG</a></span><u></u><u></u></p></div><div><p class="MsoNormal">On 08/06/2015 17:45, Rémi Cura wrote:<u></u><u></u></p></div><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt"><div><div><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Courier New"">if you have start and end point of geom B,<br>you can get the river path with a shortest path method (one liner using python, can be done in few hours using plpgsql).<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">The idea is that you cut your geom into segments(pairs of points)<br>, the length of the segment is the weight of this edge <br>, and you know which segment is connected to which segment (adjacency graph).<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">Then you use <a href="http://networkx.lanl.gov/reference/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html#networkx.algorithms.shortest_paths.generic.shortest_path" target="_blank">Networkx </a>shortest path distance.<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New""><br>Else, <u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">you are up to use some nasty workaround I suppose (playing with buffers on your original river surface, testing which segment intersects etc. ).<u></u><u></u></span></p></div><div><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Courier New"">I tried that but it ends up being more work (and more corner cases) than doing the things properly (in my experience).<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">Cheers,<u></u><u></u></span></p></div><div><p class="MsoNormal"><span style="font-family:"Courier New"">Rémi-C<u></u><u></u></span></p></div></div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">2015-06-08 16:42 GMT+02:00 toni hernández <<a href="mailto:toni@sigte.udg.edu" target="_blank">toni@sigte.udg.edu</a>>:<u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Arial","sans-serif"">Hi everyone,<br><br>I have a multilinestring with a river and all its afluents as you can see in this image <br><a href="http://sigserver4.udg.edu/apps/geometries.png" target="_blank">http://sigserver4.udg.edu/apps/geometries.png</a><br><br>I got geometry A using St_StraithSkeleton.<br><br>Is there a way to go from geometry A to geometry B?? <br>Maybe something similar to SmoothLine???<br><br></span><u></u><u></u></p><div><p class="MsoNormal" style="margin-bottom:12.0pt">-- <br><b><span style="font-size:8.5pt">Toni Hernández Vallès</span></b><span style="font-size:8.5pt"> <br>Servei de Sistemes d'Informació Geogràfica i Teledetecció<br>-<br>Universitat de Girona<br><b>SIGTE</b><br>-<br>Pl. Ferrater Mora 1<br>17071 Girona<br>Tel +34 972 418 039 (7026 intern)<br><a href="mailto:toni@sigte.udg.edu" target="_blank">toni@sigte.udg.edu</a> <br><br><a href="http://www.sigte.udg.edu" target="_blank">http://www.sigte.udg.edu</a><br>Twitter <a href="http://twitter.com/SIGTE_UDG" target="_blank">http://twitter.com/SIGTE_UDG</a></span><u></u><u></u></p></div></div><p class="MsoNormal"><br>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal"><br><br><br><u></u><u></u></p><pre>_______________________________________________<u></u><u></u></pre><pre>postgis-users mailing list<u></u><u></u></pre><pre><a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><u></u><u></u></pre><pre><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><u></u><u></u></pre></blockquote><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></blockquote></div><br></div>