levelplot

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

Add XY points to raster map generated by levelplot

主宰稳场 提交于 2019-12-04 10:59:22
问题 I have raster maps which are generated using the raster package in R. These raster layers can be visualized using the rasterVis package's levelplot function: levelplot(rasterstack, layout=c(1, 2), col.regions=colorRampPalette(c('darkred', 'red3', 'orange2', 'orange', 'yellow', 'lightskyblue', 'steelblue3', 'royalblue3', 'darkblue'))) Now, I would like to add some z values defined by xy cordinates to the levelplot map. The dataframe containing z values has 4 columns. Columns 1 & 2 contain x &

Using patterns in addition/instead of background colors in lattice plots

不羁岁月 提交于 2019-12-04 07:39:01
I am using level plots from the R lattice package. My resulting plots look like the one shown below. My problem now is that I need to generate a black and white version for printing. Is there a way to change the colors to grayscale and give the rectangles a background pattern so the the red once are distinguishable from the blue ones? For example, dots or diagonal dashes come to mind. Thanks! I found a way to manually draw into the levelplot panel and to draw a diagonal fill pattern over all cells with values greater than 0.5 However, I couldn't manage to draw the same pattern in the color key

Relassify continuous raster data into binned classes with discrete colors

孤人 提交于 2019-12-04 06:18:31
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(reclassras, col.regions = col) Below is the dput of my raster layer: ras=new("RasterLayer" , file = new("

Use layout function within levelplot

孤街醉人 提交于 2019-12-03 20:57:30
I am doing mapping in R and found the very useful levelplot function in rasterVis package. I will like to display multiple plots in a window. However, par(mfcol) does not fit within lattice . I found layout function very useful in my case but it fails to perform what I want to do. Here is my code: s <- stack(Precip_DJF1, Precip_DJF2, Precip_DJF3, Precip_DJF4, Precip_DJF5, Precip_DJF6) levelplot(s, layout(matrix(c(1, 2, 0, 3, 4, 5), 2, 3)), at=seq(floor(3.81393), ceiling(23.06363), length.out=20), par.settings=themes, par.strip.text=list(cex=0), scales=list(alternating=FALSE)) Using layout

Add XY points to raster map generated by levelplot

徘徊边缘 提交于 2019-12-03 13:32:36
I have raster maps which are generated using the raster package in R. These raster layers can be visualized using the rasterVis package's levelplot function: levelplot(rasterstack, layout=c(1, 2), col.regions=colorRampPalette(c('darkred', 'red3', 'orange2', 'orange', 'yellow', 'lightskyblue', 'steelblue3', 'royalblue3', 'darkblue'))) Now, I would like to add some z values defined by xy cordinates to the levelplot map. The dataframe containing z values has 4 columns. Columns 1 & 2 contain x & y coordinates, column 3 contains z values for map 1 in layout(1, 1) and column 4 for layout(1, 2). The

Raster map with discrete color scale for negative and positive values R

帅比萌擦擦* 提交于 2019-12-03 09:31:42
I have two dataframes which I will like to map. The dfs have the same xy coordinates and I need a single colorbar with a visible discrete color scale for both dfs like the one shown here. I would like the colors in the colorkey to match the self-defined breaks. a more general solution that can be applied outside this example is much appreciated The RdYIBu color palette from the RcolorBrewer package is what I am after. My code so far: library(rasterVis) ras1 <- raster(nrow=10,ncol=10) set.seed(1) ras1[] <- rchisq(df=10,n=10*10) ras2=ras1*(-1)/2 s <- stack(ras1,ras2) Uniques <- cellStats(s,stat

How do I specify different color ranges for different levels?

淺唱寂寞╮ 提交于 2019-12-03 06:22:11
I am making a lattice levelplot from x and y factors that range from [0,1]: x y level 1 m3134 m3134 1.0000000 2 m3134 m416B 0.4189057 3 m416B m3134 0.2696508 4 m3134 mA20 0.3322170 5 mA20 m3134 0.2454191 6 m3134 mB 0.3176792 ... Here is the R script that I use to make the figure from this data: #!/foo/bar/bin/Rscript --vanilla args <- commandArgs(TRUE) mtxFn <- args[1] pdfFn <- args[2] mtx <- read.table(mtxFn, col.names=c("x", "y", "level")) mtx$level[(mtx$level == 1)] <- NA library(lattice) trellis.device(dev=pdf, file=pdfFn) colors <- colorRampPalette(c('red', 'white'))(256) fig <- levelplot

Visualize negative/positive data using levelplot in R

一笑奈何 提交于 2019-12-02 07:03:13
I need your insights on how to visualize/map data that span negative and positive values. I have 6 rasters which have been stacked together ( s ) and will subsequently be plotted via the levelplot function in R. Below are the max and min values for each raster . 39.2887, 53.09207 (min, max) # r1 -32.4956, -27.25534 (min, max)# r2 -14.37683, -11.37742 (min, max)# r3 9.512934, 13.60197 (min, max)# r4 -4.993901, -1.851784 (min, max)# r5 -8.190711, -5.104764 (min, max)# r6 At the moment, I am able to produce my map via: library(raster) library(rasterVis) library(colorRamp) s <- stack(r1,r2,r3,r4

How to rotate the x-axis labels 90 degrees in levelplot

梦想与她 提交于 2019-11-28 23:29:12
I'm trying to visualize a correlation map, and I think that I've gotten it to work, except for the jumbling of the x-axis labels. Any suggestions for how to rotate them? Some of the parameters for many of the Base R plots don't seem available for levelplots. It's possible that I don't know what I'm talking about. This is the data I used: cor2<-structure(c(1, -0.0389681095266643, -0.0389681095266643, 0.178476154216706, -0.178476154216706, -0.168494117498168, -0.0531355593389041, -0.0627159607856109, -0.11922152176561, 0.00887070126495505, -0.0721998017906867, -0.140654273521441, 0