On Mon, 14 Jun 2010, Leonardo Hardtke wrote:

Hi list,
I'm tryng to do a simple random subset of spatial points in R and don't know how....
I tried:

library(spgrass6)
hs=readVECT6("hs...@hot_spot") (3500 point) #SpatialPointDataFrame
hs_smpl=spsample(hs, 200, "random")  #->SpatialPoints

Why do you thing that this is a subsample of your points? It is a sample of 200 points in the bounding box of your points, I think. To subsample, generate a new object by subsetting on row indices in the sample:

library(sp)
data(meuse)
coordinates(meuse) <- c("x", "y")
nrow(meuse)
plot(meuse, axes=TRUE)
plot(spsample(meuse, n=50, type="random"), col="red", add=TRUE)
plot(meuse[sample(x=nrow(meuse), size=50),], col="blue", pch=16, add=TRUE)


Hope this helps,

Roger


the question is... how do I attach the right data?
Thanks!

Leonardo Hardtke
_______________________________________________
grass-stats mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-stats


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

_______________________________________________
grass-stats mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-stats

Reply via email to