[R-sig-Geo] Receiving ID of polygons when intersecting SpatialPolygons(DataFrame) and SpatialPoints
Roman Luštrik
roman.lustrik at gmail.com
Thu Oct 8 09:28:19 CEST 2015
Hello,
check out the example section of `?sp`.
# return the number of points in each polygon:
sapply(over(sr, geometry(meuse), returnList = TRUE), length)
r1 r2 r3 r4
50 57 48 0
where names in the result should be sufficiently informative.
sapply(slot(sr, "polygons"), slot, name = "ID")
[1] "r1" "r2" "r3" "r4"
Cheers,
Roman
On Thu, Oct 8, 2015 at 9:14 AM, Vv <venek at gmx.at> wrote:
> Hi list,
>
> I am currently tackling with the sp function over.
>
> I intersect a SpatialPoints object with a SpatialPolygonsDataFrame.
> I'd like to know how I can receive the ID of the polygons within the
> Polygons slot of the SpatialPolygonsDataFrame which are intersecting the
> SpatialPoints?
>
> Overlap<-sp::over(spPoints, spPolyDataFrame, returnList=TRUE)
>
> Whenever I use over I just receive "1" as result.
>
> Or is there a way to intersect SpatialPoints with objects of class
> polygons that I miss?
>
> Best,
> Ena
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
--
In God we trust, all others bring data.
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list