<div dir="ltr">Do you really need st_intersects?<div><br></div><div>Can you use ST_Dwithin(point, line, your_precision) instead?</div><div><br></div><div>Cheers,</div><div><br></div><div>Rémi-C</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/10/29 franco base <span dir="ltr"><<a href="mailto:frenk.calza@gmail.com" target="_blank">frenk.calza@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Thanks Remi</div><div>You are very clear now.</div><div> </div><div>Meanwhile I make some test and I think there is a bug somewhere.</div><div>I use the ST_ClosestPoint example documenation</div><div> </div>

<div> </div><div> </div><div>SELECT   ST_AsText(ST_ClosestPoint(pt,line)) AS cp_pt_line, <br>                 ST_AsText(ST_ClosestPoint(line,pt)) As cp_line_pt, <br>                 ST_Contains(line, ST_ClosestPoint(line,pt)), --- f<br>

                 ST_Intersects (line, ST_ClosestPoint(line,pt)), --- f<br>                 ST_Distance (line, ST_ClosestPoint(line,pt)), ---- 0<br>                 ST_Line_Locate_Point (line, ST_ClosestPoint(line,pt)) --- return value<br>

 <br>FROM </div><div>(SELECT 'POINT(100 100)'::geometry As pt, <br>                 'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry As line ) As foo</div><div> </div><div> </div><div>give this output:</div>

<div> </div><div>"cp_pt_line";"cp_line_pt";"st_contains";"st_intersects";"st_distance";"st_line_locate_point"<br>"POINT(100 100)";"POINT(73.0769230769231 115.384615384615)";f;f;0;0.828619715102687</div>

<div> </div><div> </div><div>Something is wrong</div><div> </div><div> </div><div> </div><div> </div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/29 Rémi Cura <span dir="ltr"><<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey sorry for being unclear.<br><br><div>I put you a pseudo code and some explanation :</div><div><ul><li>

first you work with real world data (observation, measure), which are of a given precision (showing the uncertainty of the measure).<br>
If your data are real world observation ,they may be precise up to the centimeter, the meter , whatever. So there is no significance of keeping XXX digits after the comma.</li><li>Second about translating : for your computer manipulating a number like 650254,2354 is not the same as manipulating a number like 254,2354.<br>


Numbers are represented with double precision, which can be precise up to<b> 15 digits </b>thanks to postgres. Keeping the number of digits low in your coordinates "free" some precision for computing. You can translate by any number as long as it reduce the number of digits in the coordinates. <br>


You can also manually translate like : x := x - 859 ; y:= y - 87426.</li><li>Third : about ST_ClosestPoint : if you point are a result of a previous computing, they are already of limited precision, thus you have to compensate this by manually putting the points onto the lines (using ST_ClosestPoint will give you a new point corresponding to old point projected onto line).</li>


</ul></div><div><br></div><div><br></div><div>Here is the pseudo code</div><div><br></div><div>--if your data are of limited precision (always the case ! )</div><div>snap to grid (your data precision)</div><div><br></div>


<div>--before computation</div><div>translate everyting (-(min_x+max_x)/2, -(min_y+max_y)/2)</div><div><br></div><div>--computation : do your spatial test</div><blockquote style="margin:0px 0px 0px 40px;padding:0px;border:currentColor">


<div>--if  precision issue not solved, use ST_ClosestPoint to project your point onto lines</div><div><br></div></blockquote><div>--after computation </div><div>translate everyting (+(min_x+max_x)/2, +(min_y+max_y)/2)<br>


</div><div><br></div><div>Cheers,</div><div><br></div><div>Rémi-C</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/29 franco base <span dir="ltr"><<a href="mailto:frenk.calza@gmail.com" target="_blank">frenk.calza@gmail.com</a>></span><br>


<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div dir="ltr"><div>Ayway</div><div>St_split and St_snap don't work</div>

<div> </div><div>SELECT line,<br>point,<br>
st_contains (st_snap (geom_line, geom_point,0.001), geom_point),<br>st_geometrytype ((st_dump(ST_split(st_snap (geom_line, geom_point,0.001), geom_point))).geom),<br>
(st_dump(ST_split(st_snap (geom_line, geom_point,0.001), geom_point))).geom as splitted_geometry</div><div> </div><div>give</div><div> </div><div>"id";"line";"point";"st_contains";"st_geometrytype";"splitted_geometry"<br>



1;7646;11764;t;"ST_LineString";"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE3353415713362F611F37410D996234AF335341"<br>



2;7646;11764;t;"ST_LineString";"0102000020BB0B0000020000005713362F611F37410D996234AF33534123B9FC675020374112143FF6BC335341"<br>3;7646;11769;t;"ST_LineString";"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE3353415EF0DD584620374139BF2762BC335341"<br>



4;7646;11769;t;"ST_LineString";"0102000020BB0B0000020000005EF0DD584620374139BF2762BC33534123B9FC675020374112143FF6BC335341"<br>5;7646;11762;t;"ST_LineString";"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE335341A5CBC785841F374156A2A33CB1335341"<br>



6;7646;11762;t;"ST_LineString";"0102000020BB0B000002000000A5CBC785841F374156A2A33CB133534123B9FC675020374112143FF6BC335341"<br></div><div> </div><div>St_geometrytype=ST_LineString but in qgis I have point and line.</div>



<div> </div><div>point splitted geometry (id =2,4,6) = geom_point (starting gometry)</div><div>line splitted geometry  (id =1,3,5)  = geom_line (starting gometry)</div></div><div><div><div class="gmail_extra">
<br><br><div class="gmail_quote">
2013/10/29 franco base <span dir="ltr"><<a href="mailto:frenk.calza@gmail.com" target="_blank">frenk.calza@gmail.com</a>></span><br><blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">



<div dir="ltr"><div>Hi.</div><div>Yes the cause can be that every function has his own "tolerance"</div><div> </div><div>SELECT line,geom_line,point,geom_point,<br>ST_ClosestPoint(geom_line,geom_point), ----- return geometry=geom_point<br>




ST_distance (geom_line,geom_point), ---- return 0<br>ST_contains(geom_line,geom_point) ---- return false</div><div> </div><div>"line";"geom_line";"point";"geom_point";"st_closestpoint";"st_distance";"st_contains"<br>




7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11764;"0101000020BB0B00005713362F611F37410D996234AF335341";"0101000020BB0B00005713362F611F37410D996234AF335341";0;f<br>




7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11769;"0101000020BB0B00005EF0DD584620374139BF2762BC335341";"0101000020BB0B00005EF0DD584620374139BF2762BC335341";0;f<br>




7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11762;"0101000020BB0B0000A5CBC785841F374156A2A33CB1335341";"0101000020BB0B0000A5CBC785841F374156A2A33CB1335341";0;f<br>




</div><div> </div><div>Remi I don't undesrtand very well your tip to translate date and use St_SnapToGrid</div><div> </div><div>I cannot snap (using St_Snap) line to point because I'm working on a road network and I cannot move the line versus point.</div>




<div> </div><div> </div><div>Thanks</div><span><font color="#888888"><div>fb</div></font></span></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/28 Rémi Cura <span dir="ltr"><<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>></span><br>




<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote"><div dir="ltr">I had the same problem, <div>all function don't react the same way when hitting precision limit.</div>




<div><br></div><div>You may want to translate your data to reduce digits, and/or use ST_SnapToGrid on everything before using ST_ClosestPoint.</div>
<div><br></div><div>Cheers,</div><div>Rémi-C</div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/28 Nicolas Ribot <span dir="ltr"><<a href="mailto:nicolas.ribot@gmail.com" target="_blank">nicolas.ribot@gmail.com</a>></span><br>





<blockquote style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid" class="gmail_quote">Hmm this is strange:<br>
<br>
Finding the closest point (st_closestPoint) or using<br>
st_lineLocatePoint to project point onto the line does not work either<br>
on the provided dataset.<br>
Though the st_distance(line, point) returns 0.<br>
<span><font color="#888888"><br>
Nicolas<br>
</font></span><div><div><br>
<br>
<br>
On 28 October 2013 18:42, Rémi Cura <<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>> wrote:<br>
> You may want to split not with point but with the projected point one line<br>
> (use <a href="http://postgis.refractions.net/docs/ST_ClosestPoint.html" target="_blank">http://postgis.refractions.net/docs/ST_ClosestPoint.html</a>)<br>
> If it is not enough, you may want to translate all your geometries to reduce<br>
> the number of digits in coordinates.<br>
> Another possibility is to use ST_Snap to snap line to point (won't work the<br>
> other way)<br>
><br>
> Cheers,<br>
> Rémi-C<br>
><br>
><br>
> 2013/10/28 Nicolas Ribot <<a href="mailto:nicolas.ribot@gmail.com" target="_blank">nicolas.ribot@gmail.com</a>><br>
>><br>
>> Hi,<br>
>><br>
>> The points are not on the line, probably due to rounding errors.<br>
>><br>
>> st_contains(line, point) returns false.<br>
>><br>
>> Nicolas<br>
>><br>
>> On 28 October 2013 18:07, franco base <<a href="mailto:frenk.calza@gmail.com" target="_blank">frenk.calza@gmail.com</a>> wrote:<br>
>> > Hi.<br>
>> > I have a set of linestring and point on linestring.<br>
>> > I want cut the linestring on the point.<br>
>> > I can have n points for one linestring,<br>
>> > so I use ST_Split<br>
>> > (insted of ST_Line_Interpolate_Point and ST_Line_Substring)<br>
>> > but it doesn't work.<br>
>> ><br>
>> > line;geom_line;point;geom_point<br>
>> ><br>
>> > 7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11764;"0101000020BB0B00005713362F611F37410D996234AF335341"<br>






>> ><br>
>> > 7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11769;"0101000020BB0B00005EF0DD584620374139BF2762BC335341"<br>






>> ><br>
>> > 7646;"0102000020BB0B000006000000A4703D0A471F37412D211F04AF335341FAEDEBE0491F3741325530C2AE335341BD5296014F1F37418FC2F578AE3353414694F606521F3741D2DEE07BAE3353412D211F74541F37418FC2F578AE33534123B9FC675020374112143FF6BC335341";11762;"0101000020BB0B0000A5CBC785841F374156A2A33CB1335341"<br>






>> ><br>
>> > ST_GeometryType(St_Split(geom_line, geom_point))<br>
>> > give "ST_GeometryCollection"<br>
>> ><br>
>> > but<br>
>> ><br>
>> > (ST_Dump(ST_Split(geom_line, geom_point))).geom<br>
>> ><br>
>> > return only 3 linestring (one for record) and the geometry is egual to<br>
>> > geom_line<br>
>> ><br>
>> ><br>
>> > thanks.<br>
>> ><br>
>> > fb<br>
>> ><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><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><br>
><br>
><br>
><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><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><br>
</div></div></blockquote></div><br></div>
</div></div><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><br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div><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><br></blockquote></div><br></div>
</div></div><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><br></blockquote></div><br></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>