[R-sig-Geo] For each point, distance to nearest point in second dataset
nickeubank at gmail.com
Fri May 20 00:38:12 CEST 2016
For other's reference, that was almost right:
To get distance from each voter to closest polling place, the syntax was:
knn.results = knn(data=coordinates(polling.places),
On Thu, May 19, 2016 at 3:03 PM Nick Eubank <nickeubank at gmail.com> wrote:
> Thanks Michael!
> Super easy context: two SpatialPointsDataFrames ("voters",
> "polling.places"). Each has coordinate columns "x" and "y".
> Is it just:
> knn(voters, query = polling.places, k=1)
> On Thu, May 19, 2016 at 2:59 PM Michael Sumner <mdsumner at gmail.com> wrote:
>> Use nabor package, it takes a little to learn but is crazy fast.
>> Happy to show if you make a relevant example.
>> On Fri, May 20, 2016, 06:42 Nick Eubank <nickeubank at gmail.com> wrote:
>>> Hi All,
>>> Trying to an equivalent to the "nearest" tool in ArcGIS for two
>>> SpatialPointDataFrames. I can do the naive implementation by calculating
>>> all pairwise distances using gDistance and taking the min, but I have
>>> huge datasets and was looking for something more efficient. (For example,
>>> here's a trick with knearneigh for points in same dataset (
>>> Any suggestions?
>>> [[alternative HTML version deleted]]
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>> Dr. Michael Sumner
>> Software and Database Engineer
>> Australian Antarctic Division
>> 203 Channel Highway
>> Kingston Tasmania 7050 Australia
[[alternative HTML version deleted]]
More information about the R-sig-Geo