[R-sig-Geo] Which dimension should a matrix returned by a binary topological operaor have?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Sep 7 13:47:40 CEST 2016


In sp and rgeos, we currently have

> library(sp)
> library(rgeos)
> p1 = SpatialPoints(matrix(1:4,2))
> p2 = SpatialPoints(matrix(1:6,3))
> gRelate(p1,p2,byid=TRUE)
  1           2
1 "FF0FFF0F2" "FF0FFF0F2"
2 "FF0FFF0F2" "FF0FFF0F2"
3 "FF0FFF0F2" "FF0FFF0F2"
> dim(gRelate(p1,p2,byid=TRUE))
[1] 3 2
> length(p1)
[1] 2
> length(p2)
[1] 3

Meaning: arguments with lengths 2 and 3 result in a 3 x 2 matrix. This
is true for all binary operators (covers, intersects, etc) and byid=TRUE.

I always found this counterintuitive, and consider implementing it the
other way around (2 and 3 -> 2 x 3) in package sf. Or am I overlooking
something obvious?
-- 
Edzer Pebesma
Institute for Geoinformatics  (ifgi),  University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software:   http://www.jstatsoft.org/
Computers & Geosciences:   http://elsevier.com/locate/cageo/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20160907/616a5685/attachment.bin>


More information about the R-sig-Geo mailing list