rastervis

rasterVis - setting the bottom plots in the middle with levelplot

筅森魡賤 提交于 2021-01-28 09:36:26
问题 I am using the awesome rasterVis to create a panel with maps that have the same extent (i.e. same spatial coverage) but that show different features (i.e. each with its own legend). This is what it looks like so far: library(raster) library(rasterVis) library(RColorBrewer) library(gridExtra) # make-up data r <- raster(system.file("external/test.grd", package="raster")) s <- stack(r, r*2, r*3, r*4, r*5) names(s) <- paste0("Field ",seq(1,5)) # pre-allocate list l <- vector("list", length

rasterVis - setting the bottom plots in the middle with levelplot

微笑、不失礼 提交于 2021-01-28 09:32:47
问题 I am using the awesome rasterVis to create a panel with maps that have the same extent (i.e. same spatial coverage) but that show different features (i.e. each with its own legend). This is what it looks like so far: library(raster) library(rasterVis) library(RColorBrewer) library(gridExtra) # make-up data r <- raster(system.file("external/test.grd", package="raster")) s <- stack(r, r*2, r*3, r*4, r*5) names(s) <- paste0("Field ",seq(1,5)) # pre-allocate list l <- vector("list", length

How to create irregular color scale in levelplot?

て烟熏妆下的殇ゞ 提交于 2020-03-28 06:47:29
问题 Somebody can help me to create color scale like this picture. I have tried a basic code below, but didn't work well... chl <- colorRampPalette(c('midnight blue','cyan 4','green 3','yellow','goldenrod 3','tomato 3')) levelplot(raster_name, col.regions = chl, at=c(0.03, 0.1, 0.4, 2, 10, 30), margin=FALSE, ylab='Latitude', xlab='Longitude') 来源: https://stackoverflow.com/questions/60702075/how-to-create-irregular-color-scale-in-levelplot

Plotting a raster with exponential or quantile color ramp diverging around zero

做~自己de王妃 提交于 2019-12-24 14:07:54
问题 I am using the R function levelplot() from the rasterVis package to plot a stack of three rasters with a single diverging color ramp. I would like to change the scale of a raster color ramp so that the map accentuates differences in lower values. This can be done by non-linear binning of the color breaks. I'm using the code from a gist written by @jbaums (code included below). Any suggestions on how to adjust the color ramp in this code so that the breaks follow 2^x but the min and max values

Levelplot color key - range and extremes

隐身守侯 提交于 2019-12-21 05:16:10
问题 Is it possible in R to create a color key like the one below? (this one comes from the software Grid Analysis and Display System - Grads). There are two features that I can't reproduce in R: The sequence is non linear however it is displayed as if Values bigger than 200 are grey / Values smaller than 0 are white I'm using levelplot from rastervis that plots rasters using the lattice levelplot: require(raster) require(rasterVis) set.seed(200) X = seq(-40,0,by=1) Y = seq(-60,-40,by=1) grid =

plot raster with discrete colors using rasterVis

别来无恙 提交于 2019-12-13 04:53:17
问题 I have a few rasters I would like to plot using gplot in the rasterVis package. I just discovered gplot (which is fantastic and so much faster than doing data.frame(rasterToPoints(r))). However, I can't get a discrete image to show. Normally if r is a raster, I'd do: rdf=data.frame(rasterToPoints(r)) rdf$cuts=cut(rdf$value,breaks=seq(0,max(rdf$value),length.out=5)) ggplot(rdf)+geom_raster(aes(x,y,fill=cuts)) But is there a way to avoid the call to rasterToPoints? It is very slow with large

Use animate() with series of levelplots in R raster

北城余情 提交于 2019-12-07 07:15:13
问题 I have a time series of 25 yearly land cover rasters. As this is categorical data, I use levelplot(inputRaster) (part of the rasterVis library) to plot a single raster. However, I would like to sequentially plot the yearly rasters, as the animate function of the raster library does. When I use rasStack <- stack(listOfRasters) animate(rasStack) The result does not have a categorical legend. So in short: how can I combine the functionalities of levelplot and animate ? 回答1: Function animate only

Relassify continuous raster data into binned classes with discrete colors

[亡魂溺海] 提交于 2019-12-06 01:27:06
问题 I would like to: Reclassify the raster ras into nine classes using reclassify Provide a colorkey with values written beside each colour (see sample plot below). The colorkey should not be split, as in the sample plot, but rather shown as a single colour ramp with 9 colours. Display the data using levelplot function (this I can do) Thanks for your help. AEZ library(rasterVis) Please use these colors: col <- colorRampPalette(c("yellow4", "yellow", "orange", "red3", "darkred")) levelplot

Use animate() with series of levelplots in R raster

Deadly 提交于 2019-12-05 12:35:16
I have a time series of 25 yearly land cover rasters. As this is categorical data, I use levelplot(inputRaster) (part of the rasterVis library) to plot a single raster. However, I would like to sequentially plot the yearly rasters, as the animate function of the raster library does. When I use rasStack <- stack(listOfRasters) animate(rasStack) The result does not have a categorical legend. So in short: how can I combine the functionalities of levelplot and animate ? Function animate only accepts raster objects as input. You can try saveGIF to animate levelplots: library(raster) library

multiple (rasterVis) levelplots

五迷三道 提交于 2019-12-04 12:14:27
问题 i'm quite desperate trying to adjust two levelplots of one rasterstack each on one plot. It seems like rasterVis::levelplot does not take the par(mfrow = c(...)) option for splitting the pane. An example using two rasterstacks that shall be arranged side by side on a new plot window : f <- system.file("external/test.grd", package="raster") r1 <- stack(raster(f),log(raster(f))) r2 <- stack(raster(f)-500,raster(f)+500) par(mfrow=c(2,2)) levelplot(r1) levelplot(r2) Here, levelplot(r1) is being