[R-sig-Geo] raster package display

Lyndon Estes lestes at princeton.edu
Wed Jun 29 18:28:34 CEST 2011


Hi Colin,

How many colors are actually displayed?  I find that the legend/scale
bar often shows a range of values, even though there is only one value
in the raster.

For instance if I do this:

dummy <- raster(extent(-100, 100, -200, 200))
dummy[] <- 1
plot(dummy)

I have the same values as you in the scale bar, but there is only one
color (yellow), which corresponds to value 1.

I suppose one could make a custom legend to display just a single
value, but I usually just ignore this.

Hope this helps.

Cheers, Lyndon

On Wed, Jun 29, 2011 at 11:50 AM, Colin Robertson <colinr23 at gmail.com> wrote:
> Dear List,
>
> I am creating a raster as the output of a function, and for testing
> purposes the output of this function should be a raster with all 1's.
>
> When I check with summary, this is the case:
>
> class(out[[2]])
> [1] "RasterLayer"
> attr(,"package")
> [1] "raster"
>
> summary(out[[2]])
> Cells:  1600
> NAs  :  304
>
> Min.      1
> 1st Qu.   1
> Median    1
> Mean      1
> 3rd Qu.   1
> Max.      1
> NA's    304
>
> Yet when I plot using plot(out[[2]]), I get a display of values
> ranging from 0.6 - 1.4.
>
> All summaries on the raster indicates all cells have value of 1, but
> the display shows differently.
>
> Any ideas on what is happening here much appreciated,
>
> Thanks -
>
> Colin
>
> _______________________________________________
> 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