Ned,
In sampleRegular the gain/offset correction was applied twice in some cases.
This has been fixed, I believe, in version 1.9-27, that I have just sent to
CRAN.
Thanks for reporting this.
Robert

On Fri, Oct 7, 2011 at 1:59 PM, Ned Horning <horning@amnh.org> wrote:

> Hi - I am working on a topographic correction script and am having a
> problem with the gain and offset settings.
>
> This is how I set the gain and offset:
> gainVal <- 0.108078
> offsetVal <- -0.37
> gain(satImage) <- gainVal
> offs(satImage) <- offsetVal
>
> When I look at the gain/offset values they look fine:
> > gain(satImage)
> [1] 0.108078
> > offs(satImage)
> [1] -0.37
>
> When I get a bunch of samples using sampleRegular (or sampleRandom) the
> retrieved values are not correct:
> > satImageSamps <- sampleRegular(satImage, numSamps, cells=TRUE)
> > head(satImageSamps)
>     cell p125r49_5t19890217_subset
> [1,] 1504                0.41935178
> [2,] 1511                0.48943690
> [3,] 1518                0.51279861
> [4,] 1525                0.40767093
> [5,] 1532                0.06892616
> [6,] 1539                0.30254324
>
> But if I extract the value for the first cell in satImageSamps the value
> looks like what I would expect:
> > extract(satImage, 1504)
> 6.871226
>
> If I run the script without altering the gain and offset values I still get
> different values for the same cell number using sampleRegular and extract
> but they are roughly the same. I have a similar problem using sampleRandom -
> the value returned for a cell is different than what I get using extract
> with the cell number.
>
> Is this a bug or am I doing something wrong?
>
> I am using raster version 1.9-19 downloaded from the CRAN.
>
> All the best,
>
> Ned
>
> ______________________________**_________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>

	[[alternative HTML version deleted]]

