[R-sig-Geo] ext option for Raster's sampleRandom not working?

Robert J. Hijmans r.hijmans at gmail.com
Thu Jun 6 02:02:40 CEST 2013

You are right, that does not work. I will fix it.

On Wed, Jun 5, 2013 at 1:56 PM, Ned Horning <horning at amnh.org> wrote:
> Hi -
> I am trying to run a script that calculates a common extent between two
> images than then uses that extent to restrict the random selection of cells
> from a raster using the sampleRandom function. For some reason it doesn't
> seem to be working although it used to work. It appears as if the "ext=TRUE"
> argument doesn't have an effect. The cells that are returned cover the
> entire image and are not restricted to the area defined by the "ext"
> variable.
> Another thing I notiiced is that when I use "xy=TRUE" along with
> "cells=TRUE" the resulting coordinates do not appear to match with the cell
> numbers. When I use "xyFromCell" to calculate the coordinates of the center
> of a cell returned from sampleRandom I get a good result but it is different
> form the coordinates for that same cell returned from sampleRandom.
> I checked the extent and it looks fine.
> Would someone be able to check if the extent feature in SampleRandom is
> working in the Raster package. If someone thinks of something I'm doing
> wrong please let me know.
> Here is the line of code I am using:
> sampleCells <- sampleRandom(predImage, size=numSamps, cells=TRUE,
> ext=commonExt)[,1]
> I'm using raster 2.1-25 with R 3.0 on Ubuntu 12.04 64 bit
> Ned
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

More information about the R-sig-Geo mailing list