Skip to main content
9 events
when toggle format what by license comment
Jun 27, 2019 at 10:36 answer added Sam timeline score: 1
Jun 26, 2019 at 13:12 comment added Spacedman as I said, read the help for ratify which includes a tiny example of a landcover factor raster (but doesn't go on to colour it, but that's not too much of a leap and is probably well-documented elsewhere).
Jun 26, 2019 at 12:41 comment added Rodrigo @Spacedman How do I tell the difference? My real world raster has color palette information, but I'm using a different palette with the col parameter on the plot function.
Jun 26, 2019 at 8:08 comment added Spacedman The raster you construct in the example has integers in it but R doesn't know it represents categorical data. The raster package supports properly categorical rasters with colour palette information.
Jun 26, 2019 at 1:16 comment added Rodrigo @mdsumner Thank you, zlim apparently solved my problem.
Jun 26, 2019 at 1:15 comment added Rodrigo @Spacedman My raster is categorical, with 23 levels. It's the GLC2000 (Global Land Cover) project.
Jun 25, 2019 at 6:36 comment added Spacedman You neeid to look at categorical rasters for mapping when your are representing discrete categories of data rather than possibly continuous numeric values. See help(raster::ratify)
Jun 25, 2019 at 1:06 comment added mdsumner In the first plot you have an implicit range (zlim) of c(1, 6), so you can get the same result with plot(crop(r,extent(c(0.5,1.5,0.5,1.5))), col = colors, zlim = c(1,6)). Whether that will work with other palette choices is unclear though, you can control more specifically with the breaks argument.
Jun 24, 2019 at 23:02 history asked Rodrigo CC BY-SA 4.0