[R-sig-Geo] point.in.polygon() or over() help?

karengrace84 kgfisher at alumni.unc.edu
Thu May 23 17:00:54 CEST 2013


I am new to mapping with R and having some trouble. Here is what I am trying
to accomplish. I am looking at fish tagging data. I have gps coordinates of
where each fish was tagged and released, and I have a map of 10 coastal
basins of the state of Louisiana. I am trying to determine which basin each
fish was tagged in, so that I can perform further analysis from there.

I've used the sp and rgdal packages to input my shp files of the coastal
basins, and I have my list of gps coordinates where the fish were tagged.
I've tried using the point.in.polygon() function and the over() function
from the sp package unsuccessfully. Can someone please tell me how to use
one of these functions correctly, or if there is a better way to reach my
goal?

For the point.in.polygon() function, I am unsure of how to get my data in
the correct format for the function. The generic form of the function is as
follows: 

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. My problem is with
the pol.x and pol.y input. My polygon is currently in the form of a
SpatialPolygonsDataFrame. 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?

Or for the over() function (x %over% y), with x as my SpatialPoints (the gps
coordinates) and y as my SpatialPolygonsDataFrame (the basin), I receive the
following error message, Error: identicalCRS(x, y) is not TRUE.

Thanks for any suggestions.



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/point-in-polygon-or-over-help-tp7583635.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list