On Sat, 28 Mar 2009, Tyler Dean Rudolph wrote:

Here are the sessionInfo() and traceback() results following the failed
import.  It looks like I am not using the most recent version of sp so I am
trying to figure out the terms in the call to update.package() and with the
most recent version I will try again.

Thanks! The indications are that coordinates is being passed a numeric vector, not a matrix, at:

Line(coords = shape$verts[from[i]:to[i], ])

so if from[i] == to[i], the code as shown converts a single coordinate (one row) matrix into a numeric vector (omitted drop=FALSE in "[" method, perhaps the most common coding error in S/R).

That is fixable, but a better workaround may be to use readOGR() in rgdal rather than readShapeLines() in maptools.

Roger

The .shp file is ~30 megabytes and
the associated .dbf is ~15 megabytes, though I don't think the latter is
included in the import.  I have 2G of memory on this machine....

Tyler

**
*> roads<-as(as(readShapeLines(fn="D:\\GIS\\road2004.shp"), "SpatialLines"),
"psp")
*Error in function (classes, fdef, mtable)  :
 unable to find an inherited method for function "coordinates", for
signature "numeric"

*> sessionInfo()*
R version 2.8.1 (2008-12-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base

other attached packages:
[1] spatstat_1.15-0 deldir_0.0-7    gpclib_1.4-3    mgcv_1.4-1.1
maptools_0.7-20 foreign_0.8-29  sp_0.9-29
loaded via a namespace (and not attached):
[1] grid_2.8.1      lattice_0.17-17 tools_2.8.1

*> traceback()*
13: stop("unable to find an inherited method for function \"", f...@generic,

       "\", for signature ", cnames)
12: function (classes, fdef, mtable)
   {
       methods <- .findInheritedMethods(classes, fdef, mtable)
       if (length(methods) == 1)
           return(methods[[1]])
       else if (length(methods) == 0) {
           cnames <- paste("\"", sapply(classes, as.character),
               "\"", sep = "", collapse = ", ")
           stop("unable to find an inherited method for function \"",
               f...@generic, "\", for signature ", cnames)
       }
       else stop("Internal error in finding inherited methods; didn't
return a unique method")
   }(list("numeric"), function (obj)
   standardGeneric("coordinates"), <environment>)
11: coordinates(coords)
10: Line(coords = shape$verts[from[i]:to[i], ])
9: .shapes2LinesList(shapes[[i]], ID = IDs[i])
8: .shp2LinesDF(Map, proj4string = proj4string)
7: withCallingHandlers(expr, warning = function(w)
invokeRestart("muffleWarning"))
6: suppressWarnings(.shp2LinesDF(Map, proj4string = proj4string))
5: readShapeLines(fn = "D:\\GIS\\road2004.shp")
4: .class1(object)
3: as(readShapeLines(fn = "D:\\GIS\\road2004.shp"), "SpatialLines")
2: .class1(object)
1: as(as(readShapeLines(fn = "D:\\GIS\\road2004.shp"), "SpatialLines"),
      "psp")

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
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: [email protected]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to