[prev in list] [next in list] [prev in thread] [next in thread]
List: r-sig-geo
Subject: [R-sig-Geo] Expected behaviour of over() at polygon corners (sp package)
From: Paul Galpern <pgalpern () gmail ! com>
Date: 2013-03-21 14:00:15
Message-ID: 514B126F.8030206 () gmail ! com
[Download RAW message or body]
Dear R-sig-geo:
I am not sure whether the following is the intended behaviour of
sp::over() in this situation. When a point falls on the mutual corner
of three square polygons over() returns NA. One of these polygons
contains a hole in which the other two are embedded.
The following toy example uses SpatialPolygons derived from a raster
created with raster::rasterToPolygons(..., dissolve=TRUE) as this is the
process I am using to create the polygons, and the result I am getting
may be an artefact of this.
## Create example raster
library(raster)
rasCells <- matrix(c(1, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1), 4, 4)
ras <- raster(rasCells)
## Convert to SpatialPolygons
rasPoly <- rasterToPolygons(ras, dissolve=TRUE)
## Spatial overlay
## over() returns NA
pt <- cbind(0.5, 0.5)
over(SpatialPoints(pt), rasPoly)
## The offending point falls at the mutual corner of three polygons
plot(ras)
points(pt)
I recognize that there are other ways around this. Using
raster::extract() is equivalent, and I can jitter the point, for
example. But wondering what the intended behaviour of over() is, here.
Thanks--as always--to the creators of these fine tools,
Paul
--
Paul Galpern
Natural Resources Institute
70 Dysart Road
University of Manitoba
Winnipeg, Manitoba, Canada R3T 2M6
http://borealscape.ca
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic