[R-sig-Geo] raster plotting question: figured it out

Robert J. Hijmans r.hijmans at gmail.com
Wed Sep 3 23:10:04 CEST 2014


Erin,

This is not a good approach:

min1 <- min(a at data@values,b at data@values)
max1 <- max(a at data@values,b at data@values)

Because many RasterLayer objects won't have any values there. It is
another example of why you should not poke inside of S4 objects if
there are functions to do that for you.
This is a better approach:

min1 <- min(minValue(a), minValue(b))
max1 <- max(maxValue(a), maxValue(b))

Robert


On Fri, Jul 25, 2014 at 12:09 PM, Hodgess, Erin <HodgessE at uhd.edu> wrote:
> Sure!
>
>
>
> No prob:
>
>
>
> min1 <- min(a at data@values,b at data@values<mailto:a at data@values,b at data@values>)
>
> max1 <- max(a at data@values,b at data@values<mailto:a at data@values,b at data@values>)
>
> bk1 <- seq(from=min1,to=max1,len=6)  #note: make the len whatever you wish
>
> par(mfrow=c(1,2))
>
> plot(a,breaks=bk1)
>
> plot(b,breaks=bk1)
>
>
>
> Thanks!
>
>
>
> I'm glad to hear that somebody else might use it....thought I was just being a complete doofus!
>
>
>
> Take care,
>
> Erin
>
>
>
> ________________________________
> From: Michael Treglia [mtreglia at gmail.com]
> Sent: Friday, July 25, 2014 1:42 PM
> To: Hodgess, Erin
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] raster plotting question: figured it out
>
> Hey Erin,
> Could you please include the solution? I haven't had to do that, but I'm sure that I (and others) will probably have to in the future, so it may be useful to have the solution in this thread
> Thanks!
> Mike
>
>
> On Fri, Jul 25, 2014 at 2:25 PM, Hodgess, Erin <HodgessE at uhd.edu<mailto:HodgessE at uhd.edu>> wrote:
> Sorry for the trouble.
>
>
>
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org<mailto:R-sig-Geo at r-project.org>
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> 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