[R] point.in.polygon help
macqueen1 at llnl.gov
Wed May 22 22:37:37 CEST 2013
First suggestion is to ask the question on r-sig-geo.
There is the over()
function in the sp package, though it may require you to put your points
in a spatial class object.
For a crude brute-force approach that does not easily generalize, but
might be the quickest short-term solution for you right now, and assuming
your object has just a single polygon, try this:
your.spdf at polygons[]@Polygons[]@coords
That should give you a two column matrix representing your polygon.
You may need to remove the last row for pol.x and pol.y, since in this
implementation the last row = the first row.
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
On 5/21/13 1:29 PM, "karengrace84" <kgfisher at alumni.unc.edu> wrote:
>I am new to mapping with R, and I would like to use the point.in.polygon
>function from the sp package, but I am unsure of how to get my data in the
>correct format for the function. The generic form of the function is as
>point.in.polygon(point.x, point.y, pol.x, pol.y, mode.checked=FALSE)
>I have no problem with the point.x and point.y inputs. I have a list of
>longitudes and latitudes that will go in fine. My problem is with the
>and pol.y input. My polygon is currently in the form of a
>SpatialPolygonsDataFrame created by inputting shp files with the rgdal
>How do I get a numerical array of the x- and y-coordinates from my polygon
>that will go into the point.in.polygon function?
>View this message in context:
>Sent from the R help mailing list archive at Nabble.com.
>R-help at r-project.org mailing list
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.
More information about the R-help