Re: [R] Points inside a polygon

2012-01-12 Thread Rolf Turner

On 12/01/12 17:28, Hasan Diwan wrote:

I have a list of bounds for a series of polygons. I do understand the
formula to determine whether point i is within polygon X (X[x1]<  i[x]
&  X[x2]>  i[x]&  X[y1]<  i[y]&  X[y2]>  i[y]), and I can apply this
throughout the dataset. However, this naive algorithm doesn't scale
very well. The data set contains 10,000 points consisting of (n,e)
pairs where I'm interested in which are inside polygons denoted by
vertices (V[x1]/V[y1],V[x2],V[y2]). Is there a shortcut to accomplish
this goal? Many thanks!  --


You could use the function inside.owin() in the "spatstat" package
(after appropriately reconfiguring your polygons as objects of class
"owin"; something like w <- owin(poly=plygn) where "plygn" is your
polygon).

You could also use the undocumented function inside.xypolygon().

cheers,

Rolf Turner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Points inside a polygon

2012-01-12 Thread Justin Haynes

On Wed 11 Jan 2012 08:28:03 PM PST, Hasan Diwan wrote:

I have a list of bounds for a series of polygons. I do understand the
formula to determine whether point i is within polygon X (X[x1]<  i[x]
&  X[x2]>  i[x]&  X[y1]<  i[y]&  X[y2]>  i[y]), and I can apply this
throughout the dataset. However, this naive algorithm doesn't scale
very well. The data set contains 10,000 points consisting of (n,e)
pairs where I'm interested in which are inside polygons denoted by
vertices (V[x1]/V[y1],V[x2],V[y2]). Is there a shortcut to accomplish
this goal? Many thanks!  -- H



Check out the splancs package.  particularly the inout function.

Justin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Points inside a polygon

2012-01-11 Thread Hasan Diwan
I have a list of bounds for a series of polygons. I do understand the
formula to determine whether point i is within polygon X (X[x1] < i[x]
& X[x2] > i[x] & X[y1] < i[y] & X[y2] > i[y]), and I can apply this
throughout the dataset. However, this naive algorithm doesn't scale
very well. The data set contains 10,000 points consisting of (n,e)
pairs where I'm interested in which are inside polygons denoted by
vertices (V[x1]/V[y1],V[x2],V[y2]). Is there a shortcut to accomplish
this goal? Many thanks!  -- H

-- 
Sent from my mobile device
Envoyait de mon portable

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.