Dear listers,

I met a trouble with spsample which has been solved by Roger Bivand off list. I though it was general enough to be of interest for other users. In brief I needed to get 50 random points on a SpatialLinesDataFrame called "hydntline" and got:

spsample(hydntline,50,type="random")
Error in function (classes, fdef, mtable)  :
unable to find an inherited method for function "coordinates", for signature "numeric"

Roger's response is the following:

The reason is that some lines are assigned no sample points, and the function tries to create a SpatialPoints object with no points. The workaround is to increase n, then reduce the output by sampling back down.

z <- spsample(hydntline,4000,type="random")
zz <- z[sample(nrow(coordinates(z)), 50)]
plot(hydntline, axes=TRUE)
points(zz, pch=3)


begin:vcard
fn:Patrick Giraudoux
n:Giraudoux;Patrick
org;quoted-printable:Universit=C3=A9 de Franche-Comt=C3=A9;Chrono-environnement, UMR UFC-CNRS 6249 usc INRA
adr;quoted-printable:;;1, place Leclerc;Besan=C3=A7on;;25030;France
email;internet:[EMAIL PROTECTED]
title;quoted-printable:Professeur d'=C3=A9cologie
tel;work:+33 381 665 745
tel;fax:+33 381 665 797
version:2.1
end:vcard

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to