[R] point.in.polygon help

MacQueen, Don macqueen1 at llnl.gov
Thu May 23 21:08:09 CEST 2013


In that case I'd definitely look more at the over() function than that
ugly bit I suggested before.

Get your fish info into a SpatialPointsDataFrame

Since your polygons are in a SpatialPolygonsDataFrame, I would expect the
data frame part has one row per basin, and it contains the basin names or
other unique identifier. Loop through the basin names, subsetting the
SpatialPolygonsDataFrame for each each basin, then use the over() function
the with the fish SpatialPointsDataFrame to tell you which fish are in the
current basin.

That's an outline; there are obviously lots of details that would be
needed.

This should work even if, for example, a single basin consists of more
than one polygon (presumably non-overlapping).

There may be a more efficient way, but I don't know it off the top of my
head.

-Don

-- 
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 5/23/13 6:03 AM, "karengrace84" <kgfisher at alumni.unc.edu> wrote:

>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. 
>
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/point-in-polygon-help-tp4667645p4667808.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>R-help at 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.



More information about the R-help mailing list