[R-sig-Geo] Maptools as.SpatialPolygons.owin() behaves in a strange way ?

Roger Bivand Roger.Bivand at nhh.no
Thu Feb 10 16:03:21 CET 2011


On Thu, 10 Feb 2011, Alexandre Villers wrote:

> Dear list users and maptools mainteners,
>
> I'm a bit confused by the behaviour of the function as.SpatialPolygons.owin()
>
> library(spatstat)
> library(maptools)
>
> disc.test<-disc(radius=1, centre=c(0,0))
> disc.sp<-as.SpatialPolygons.owin(disc.test) # <-- fails and return a error: 
> could not find function "as.SpatialPolygons.owin"
> disc.sp<-as(disc.test, "SpatialPolygons") # <-- works fine

Only the S4 coercion method as() for signature "owin", "SpatialPolygons" 
is exported in the package namespace, not the underlying function. In 
other cases, initially only the function was exported, also as an S3 
method, but when the method was converted from S3 to S4, the exporting of 
the underlying functions was not supressed, but maybe should have been. 
These are idiosyncracies that happen, because the sp class/spatstat class 
interface have developed over time, rather than being planned in a single 
step.

Hope this clarifies,

Roger

>
> On the other hand,  as.SpatialPoints.ppp(object.ppp) and as(object.ppp, 
> "SpatialPoints") work fine. I haven't tested all the possibilities between 
> spatstat and sp object, so I don't know if this "bug", if it is really one 
> (everything seems to work fine on my PC), is widespread.
> If not, I guess it was solely my Murphy's rule practise for today...
>
>
> Alex
>
> P.S.: sessionInfo()
> sion 2.12.1 (2010-12-16)
> Platform: x86_64-pc-mingw32/x64 (64-bit)
>
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United 
> Kingdom.1252    LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C 
> LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] grid      grDevices datasets  splines   graphics  stats     tcltk 
> utils     methods   base
>
> other attached packages:
> [1] gpclib_1.5-1         maptools_0.7-38      foreign_0.8-41 
> spatstat_1.21-4      deldir_0.0-13        mgcv_1.7-2           rgdal_0.6-33 
> sp_0.9-76            effects_2.0-10
> [10] colorspace_1.0-1     nnet_7.3-1           MASS_7.3-9           ncf_1.1-3 
> gplots_2.8.0         caTools_1.11         bitops_1.0-4.1       gdata_2.8.1 
> gtools_2.6.2
> [19] scatterplot3d_0.3-31 lattice_0.19-13      svSocket_0.9-51 
> TinnR_1.0.3          R2HTML_2.2           Hmisc_3.8-3 
> survival_2.36-2
>
> loaded via a namespace (and not attached):
> [1] cluster_1.13.2     Matrix_0.999375-46 nlme_3.1-97        svMisc_0.9-61 
> tools_2.12.1
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list