[R-sig-Geo] points sampled along a Line don't seem to intersect it
Roger Bivand
Roger.Bivand at nhh.no
Mon Mar 23 20:30:16 CET 2015
On Mon, 23 Mar 2015, Barry Rowlingson wrote:
> 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...
>
Had the fuzzyMM package been written in a modularised way (it places
vehicle GPS positions on OSM road lines, and needs velocity etc.), it
might have given a starting point. As Barry says, finding which road is
closest to each point is trivial (I projected too, to get more digits),
but finding the nearest GEOS point on the road isn't, because GEOS
discretises using getScale() to go to an integer grid. spsample() is also
very pushed to get n here, so the # pts is way under.
If anyone would like a brain teaser, this should be attractive!
Roger
>
>
> Barry
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 91 00
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list