[R-sig-Geo] how to do randomly sampling in raster layer

2010-08-03 Thread Mao Jianfeng
Dear r-sig-geoers, I want to randomly sample n points from regions of a raster layers, the cells denoted as NA is not included in this sampling process. And, I want to got the longitude and latitude of the sampled points. I checked the manual of raster package, I found several functions is

Re: [R-sig-Geo] how to do randomly sampling in raster layer

2010-08-03 Thread caspar hallmann
Dear Mao, You can use function rpoint from spatstat, after converting your raster object into a pixel image. consider the following: library(raster) library(spatstat) library(maptools) library(sp) # An arbitrary raster r - raster(system.file(external/test.grd, package=raster)) # plot it

Re: [R-sig-Geo] how to do randomly sampling in raster layer

2010-08-03 Thread Jacob van Etten
] how to do randomly sampling in raster layer To: Mao Jianfeng jianfeng@gmail.com Cc: r-sig-geo@stat.math.ethz.ch Date: Tuesday, 3 August, 2010, 11:15 Dear Mao, You can use function rpoint from spatstat, after converting your raster object into a pixel image. consider the following: library

Re: [R-sig-Geo] how to do randomly sampling in raster layer

2010-08-03 Thread Paul Hiemstra
On 08/03/2010 11:15 AM, caspar hallmann wrote: Dear Mao, You can use function rpoint from spatstat, after converting your raster object into a pixel image. consider the following: library(raster) library(spatstat) library(maptools) library(sp) # An arbitrary raster r-

Re: [R-sig-Geo] how to do randomly sampling in raster layer

2010-08-03 Thread Robert J. Hijmans
Dear Mao, If r is a RasterLayer, you can also do library(dismo) xy - randomPoints(r, n=100) plot(r) points(xy) Best, Robert On Tue, Aug 3, 2010 at 2:51 AM, Paul Hiemstra p.hiems...@geo.uu.nl wrote: On 08/03/2010 11:15 AM, caspar hallmann wrote: Dear Mao, You can use function rpoint