?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

?

JONON
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: How can I map numbers to colours with raster?

Pascal Oettli-2
Hello,

Did you check the arguments fo the function "plot", from the "raster"
package? For example, the "col" argument.

Regards,
Pascal


Le 29/10/2012 18:13, Jonsson a écrit :

> This code will read binary file and display it as a map. may problem is that
> this code is using a continuous colour scheme, even though I have discrete
> data (which  is a classification scheme). How can I map numbers to colours
> with raster? Please
>
> require(raster)
> conne <- file("C:\\lai.bin", "rb")
> sd<- readBin(conne, integer(), size=1,  n=360*720, signed=F)
>   y<-t(matrix((data=sd), ncol=360, nrow=720))
>   r = raster(y)
> extent(r) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90))
> plot(r)
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-can-I-map-numbers-to-colours-with-raster-tp4647742.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How can I map numbers to colours with raster?

barry rowlingson
In reply to this post by JONON
On Mon, Oct 29, 2012 at 9:13 AM, Jonsson <[hidden email]> wrote:

> This code will read binary file and display it as a map. may problem is that
> this code is using a continuous colour scheme, even though I have discrete
> data (which  is a classification scheme). How can I map numbers to colours
> with raster? Please
>
> require(raster)
> conne <- file("C:\\lai.bin", "rb")
> sd<- readBin(conne, integer(), size=1,  n=360*720, signed=F)
>  y<-t(matrix((data=sd), ncol=360, nrow=720))
>  r = raster(y)
> extent(r) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90))
> plot(r)
>

 The raster package can handle categorical rasters, but it seems
poorly documented.

 If I read in a categorical raster (land cover classification from
CORINE) then I get a raster that plots using the colour table defined
in the GeoTIFF. This comes from a 'legend' attribute which the raster
object has. This is an undocumented object of class ".RasterLegend".

 I think Robert "Raster" Hijmans has been meaning to document all this
at some point, I've been meaning to dig into it too. Its probably
worth asking further questions on R-sig-geo.

Barry

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: How can I map numbers to colours with raster?

steven mosher
In reply to this post by JONON
see the function level() in raster. also levelplot in rastervis package.
you basically create a raster attribute table coerce the raster to factor
class and plot. check geo sig i have posted the same question there
On Oct 29, 2012 2:15 AM, "Jonsson" <[hidden email]> wrote:

> This code will read binary file and display it as a map. may problem is
> that
> this code is using a continuous colour scheme, even though I have discrete
> data (which  is a classification scheme). How can I map numbers to colours
> with raster? Please
>
> require(raster)
> conne <- file("C:\\lai.bin", "rb")
> sd<- readBin(conne, integer(), size=1,  n=360*720, signed=F)
>  y<-t(matrix((data=sd), ncol=360, nrow=720))
>  r = raster(y)
> extent(r) = extent(c(xmn=-180,xmx=180,ymn=-90,ymx=90))
> plot(r)
>
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/How-can-I-map-numbers-to-colours-with-raster-tp4647742.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.