[R-sig-Geo] SpatialMultiPoints suggestions

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sun Dec 6 00:08:05 CET 2015


Thanks -- patch committed to r-forge.

On 05/12/15 22:37, Kent Johnson wrote:
> Hi,
> 
> I am starting to use SpatialMultiPointsDataFrame to hold lat/lon/altitude
> data and metadata from airplane tracks. A couple of observations:
> 
> - The documentation for SpatialMultiPoints {sp} seem to be incorrect. It
> say that the 'coords' argument is a "numeric matrix or data.frame with
> coordinates (each row is a point)". In fact the argument seems to be a list
> of such matrices, as shown in the example code.
> 
> - rbind() is not implemented for SpatialMultiPoints*; perhaps it is an
> oversight, as the other Spatial* classes have implementations of rbind().
> Here is my attempt:
> 
> rbind.SpatialMultiPoints <- function(...) {
> dots = list(...)
> names(dots) <- NULL
> stopifnot(identicalCRS(dots))
> SpatialMultiPoints(do.call(c, lapply(dots, slot, name="coords")),
> CRS(proj4string(dots[[1]])))
> }
> 
> rbind.SpatialMultiPointsDataFrame <- function(...) {
> dots = list(...)
> names(dots) <- NULL
> sp = do.call(rbind, lapply(dots, function(x) as(x, "SpatialMultiPoints")))
> df = do.call(rbind, lapply(dots, function(x) x at data))
> SpatialMultiPointsDataFrame(sp, df)
> }
> 
> 
> HTH,
> Kent
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
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/
Spatial Statistics Society http://www.spatialstatistics.info

-------------- 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/20151206/9ad60695/attachment.bin>


More information about the R-sig-Geo mailing list