[R-sig-Geo] points sampled along a Line don't seem to intersect it

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Mon Mar 23 13:30:26 CET 2015


On Mon, Mar 23, 2015 at 12:07 PM, Mathieu Rajerison
<mathieu.rajerison at gmail.com> wrote:
> pts <- spsample(rds.un, type="regular", n=100)

Your points are at least 3.9x10^-17 units from the lines:

 gDistance(pts, rds.un)
[1] 3.908727e-17

I can only think this is due to a difference in how spsample and how
rgeos interpolate lines from points. FAQ 7.31 in disguise?

I suspect you could use gBuffer on your points with a buffer width of
1e-10 to get a reliable intersection, but that would be a line segment
(or segments if the point is close to a junction) but you could
possibly just take a single point from that line geometry and in the
worst case scenario you're only 1e-10 out...



Barry



More information about the R-sig-Geo mailing list