MagicForrest / DGVMTools

R package for processing, analysing and visualising ouput from Dynamic Global Vegetation Models (DGVMs)
GNU General Public License v3.0
26 stars 22 forks source link

how to set the same colors for biomescheme? #35

Closed halima1993 closed 3 years ago

halima1993 commented 4 years ago

Hello Matthew, hope you are doing well. I want to ask a question related to biomescheme/getBiomes function. Basically I want to plot biomes for different years (past, present, future). The thing is when I plot the maps using Smith,2014 biome scheme, the colors are varied for each year. For instance the past years(150-1950) map show the "Tall Grasslands" in pink shade and on the other hand when I plot present years(1951-2005), the "Tall Grasslands" are shown in red shade. How can I give same colors to the same biomes in each three of my maps?

(P.s. you can close the previous issue of mine)

MagicForrest commented 4 years ago

Hi Halima, all good here. I am happy you are still using DGVMTools :-)

Your issue sounds like a bug in the plotting function. Something isn't working right because the idea is that by design the biomes should always plot with the same colour. Can you send me your script and data and I will try to fix it?

halima1993 commented 4 years ago

And one more question, is there any way to plot spatial maps of Plant functional types(PFTs) in a single spatial map DGVMTools?

MagicForrest commented 4 years ago

To answer your last question, do you want the dominant PFT in a gridcell? Remember you can only plot one value at any given point on a map, so you need to define exactly which PFT you want to plot. But plotting the dominant PFT is easy, look at layerOp() function with ' operator = "max.layer" '

For your main question. I didn't have time to get to it this week, but I will next week. Thanks for preparing the example!

MagicForrest commented 4 years ago

Hi Halima. I looked at your example, and I think the main problem is thing is that you weren't using plotSpatial() but rather some ggplot2 code. plotSpatial() should plot biomes with no problems, try, for example:

biomes.model.historic <- getBiomes(cpool.source, Smith2014BiomeScheme, year.aggregate.method = "mean", first.year = 1850, last.year = 1950) 
print(plotSpatial(biomes.model.historic ))

And you should be able to do the following too:

 biomes.model.present <- getBiomes(cpool.source, Smith2014BiomeScheme, year.aggregate.method = "mean", first.year = 1951, last.year = 2005)
  biomes.model.future<- getBiomes(cpool.source, Smith2014BiomeScheme, year.aggregate.method = "mean", first.year = 2006, last.year = 2100)
print(plotSpatial(list(biomes.model.historic, biomes.model.present, biomes.model.future))

Does that work for you? It should de everything except for the subsetting of the mountains. Unfortunately, on my system, the subsetting with the shapefile isn't working. I need to check that.

MagicForrest commented 3 years ago

Halima, any comments on this issue? Otherwise I will just close it.

halima1993 commented 3 years ago

thanks. you may close.