[R-sig-Geo] error when converting shapefile to psp object in spatstat

Roger Bivand Roger.Bivand at nhh.no
Wed Apr 6 14:32:29 CEST 2011


On Wed, 6 Apr 2011, david.march at uib.es wrote:

> Dear all,
>
> I'm trying to convert a shapefile into psp object of spatstat, but I found an 
> error message. I'm following the guidelness provided here: 
> http://cran.r-project.org/web/packages/spatstat/vignettes/shapefiles.pdf
>
> #script following the instructions with a sample shapefile from maptools:
> library(sp)
> library(spatstat)
> library(gpclib)
> library(maptools)
> spatstat.options(gpclib=TRUE) #here I suspect is only relevant for importing 
> polygon data
>
> setwd(system.file("shapes", package = "maptools"))
> fylk <- readShapeSpatial("fylk-val.shp")
> fdata <- slot(fylk, "data")
> fl <- as(fylk, "SpatialLines")
> fcurves <- slot(fl, "lines")
> fcurves <- lapply(fcurves, function(x) {SpatialLines(list(x))})
> fpatterns <- lapply(fcurves, as.psp)
>
> Here I get the following message error:
> Error en as.data.frame.vector(x, ..., nm = nm) :   el argumento formal "nm" 
> concuerda con múltiples argumentos especificados
>
> # also the same problem when trying:
> x <- as.psp(fylk)
>
> # and also here:
> x<-as.psp.SpatialLinesDataFrame(fylk)
>
> I'm running R version 2.12.2  for windows with the following version 
> packages:
> spatstat 1.21-6
> General Polygon Clipper Library for R (version 1.5-1)
> maptools 0.8-6
>
>
> Any about what is this error regarding some "nm" formal argument?

This is fixed thanks to a contribution by Rolf Turner to maptools on 
R-Forge. Please try:

install.packages("maptools", repos="http://R-Forge.R-project.org")

and see if it helps. Thanks for a very clear use case.

Roger

>
> Thanks in advance,
> David
>
> David March Morla
> Doctorando / PhD student
> Instituto Mediterraneo de Estudios Avanzados (UIB-CSIC)
> C/Miquel Marques,21
> 07190 Esporles
> Islas Baleares - Spain
> Tel: +34 971 611 722
> Fax: +34 971 611 761
> Email: david.march at uib.es
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
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