[R-sig-Geo] sub-selecting spatial data by distance from a different point(set)

Paul Hiemstra p.hiemstra at geo.uu.nl
Sat Nov 14 12:11:19 CET 2009


Hi Sean,

Take a look at the spDistsN1 function to calculate the distances from a 
single point to all other points. You can then make the subset based on 
the distance. What could also be an options is to build a polygon that 
has the radius around the point you are taking the distance from, and 
then use overlay to find which points are in the radius polygon. This 
might be faster when using a large dataset. I'm not sure how nto make 
the polygon, but it should be possible. But you could first take a look 
at spDistsN1.

cheers,
Paul

Sean O'Riordain wrote:
> Good afternoon,
>
> Apologies if this seems a basic question but I'm quite new to spatial
> analysis (1 week now!) and I'm reading and learning as fast as I can.
> I've read the Spatial Data task view, "Analysing spatial point
> patterns in R" by Bradley and I've ordered "Applied Spatial Data
> Analysis with R" - but it hasn't arrived yet...  I've looked and
> searched - but I'm guessing that I'm not using the right buzzwords...
>
> I have a data.frame (call it A) of about 2 million X,Y points each
> with info with various characteristics, numeric and factor.  I have a
> separate much smaller data.frame (call it B) of say 500 rows of X,Y
> and I'd like to be able to pull a subset of A, so that for each B[i,]
> I will get all rows from A that are within a given straight line
> distance (i.e. within a short 'as the crow flies' radius).
>
> Could somebody please give me some starting hints please?
>
> Thanks in advance,
> Sean O'Riordain
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>   


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul



More information about the R-sig-Geo mailing list