[R] Error when sampling from SpatialLines

Roger Bivand Roger.Bivand at nhh.no
Wed Jul 15 13:28:48 CEST 2009


Which version of the sp package are you using? In a version that is submitted
to CRAN, and available for CVS checkout from the R-spatial sourceforge
repository, a weakness was addressed when a Line object received no sample
points, either because of its shortness, or because n is small for the total
length of points. I suggest that you try the latest version of sp from the
CVS repository.

Roger Bivand

PS. The traffic that you mention about sampling on lines was on the
R-sig-geo list, not this list, so a post there might have been a better
idea.

PPS. Always state package version numbers when reporting problems, for
example by giving sessionInfo() output. For errors, always also give the
output of traceback(), or al least its first lines, which may show where the
problem arises.



Elke Moons wrote:
> 
> 
> 
> Dear forum, 
> 
> 
> 
>   
> 
> 
> 
> I am working in R 2.9.1 and I am trying to sample locations from a network
> file. Reading in nor plotting is a problem, however when I am trying to
> sample from the file I get the following message: 
> 
> 
> 
>   
> 
> 
> 
> nwlim<-readShapeLines("C:/Limburg_nwshape",
> proj4string=CRS("+init=epsg:31300")) 
> 
> 
> 
> plot(nwlim) 
> 
> 
> 
>   
> 
> 
> 
> randacc<-spsample(nwlim,n=1000,"random") 
> 
> 
> 
> Error in function (classes, fdef, mtable)  : 
> 
> 
> 
>   unable to find an inherited method for function "coordinates", for
> signature "numeric" 
> 
> 
> 
>   
> 
> 
> 
>   
> 
> 
> 
> I found a similar error message in the archives, where prof. dr. Bivand
> indicated to try to use readOGR instead of readShapeLines, however, I get
> the same error message. 
> 
> 
> 
>   
> 
> 
> 
>   
> 
> 
> 
> nwlim2<-readOGR("C:/Limburg_nwshape.shp", "Limburg_nwshape") 
> 
> 
> 
> OGR data source with driver: ESRI Shapefile 
> 
> 
> 
> Source: "C:/Limburg_nwshape.shp", layer: "Limburg_nwshape" 
> 
> 
> 
> with  60745  rows and  24  columns 
> 
> 
> 
> Feature type: wkbLineString with 2 dimensions 
> 
> 
> 
>   
> 
> 
> 
> randacc<-spsample(nwlim2,n=1000,"random") 
> 
> 
> 
> Error in function (classes, fdef, mtable)  : 
> 
> 
> 
>   unable to find an inherited method for function "coordinates", for
> signature "numeric" 
> 
> 
> 
>   
> 
> 
> 
>   
> 
> 
> 
> Can anyone help me with this issue? The shape file in itself is not so
> large (only a province was taken instead of the entire file of Belgium
> because of memory issues), only 8.11Mb. 
> 
> 
> 
>   
> 
> 
> 
> Thanks in advance! 
> 
> 
> 
>   
> 
> 
> 
> Elke 
> 
> 
> 
>   
> 
> 
> 
> __________________________________________
> 
> 
> 
> Elke Moons, PhD
> 
> 
> 
> Instituut voor Mobiliteit/Transportation Research Institute
> 
> 
> 
> Universiteit Hasselt
> 
> 
> 
> Wetenschapspark 5/Lokaal 1.10
> 
> 
> 
> 3590 Diepenbeek
> 
> 
> 
> BELGIUM
> 
> 
> 
> Tel. +32-11-26.91.26
> 
> 
> 
> Fax +32-11-26.91.99
> 
> 
> 
> E-mail: elke.moons at uhasselt.be 
> 
> 
> 
>   
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/Error-when-sampling-from-SpatialLines-tp24481180p24496005.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list