Sunday, 10 March 2019

qgis - Display two-dimensional color gradient for two different quantities


I have two overlapping raster layers. One contains quantity A from 0 to 100, and the other contains quantity B from 0 to 100. I'd like to create a map displaying both sets of data at once based on a color box with two different axes.



So, for an area where:



  • A is 100 and B is 100, the map would be red

  • A is 100 and B is 0, it would be yellow

  • A is 0 and B is 100, it would be green

  • A is 0 and B is 0, it would be blue


For intermediate values the hue would change accordingly, so A=100, B=50 would be orange; A=50, B=0 would be blueish-green.


I have seen maps display this type of data before, and I have a couple of things I'd like to display this way. What is the easiest way to do this? I can use ArcGIS, QGIS and R.



Answer




What you're trying to create is known as a bivariate map. There's a couple of ways to do this, but since you've already got raster data that leans toward certain methods. The big thing is going to be your color selections, and I'm not sure exactly how to get the blending you desire.


Typically this is done with two colors, one for each variable. So A 0 = white, A 100 = blue, B 0 = white, and B 100 = red. You would then merge the two rasters and get shades of purple where both are high, white where both are low, and a color leaning toward red or blue where one is greater than the other.


This can be adapted to two color axis. A 0 is yellow, A 100 is red and B 0 is green with B 100 blue. But then you can start to get some muddy values in the middle, depending on your colors. In this case, A and B 100 is purple, while A and B 0 is a yellow green. A 0 and B 100 is going to be gray while A 100 and B 0 is olive.


With just the three primaries, the blends are fairly clean. That fourth complicates things though. According to your question, both A and B 0 would be blue, A 100 would be yellow, B 100 is green, and both A and B 100 is red. This doesn't really work since yellow plus green isn't red. And yellow plus the midpoint of green and blue isn't orange.


I think you'll have better results if you choose just two colors. You might even get away with three (both are the same primary color low or high, but then each has a different primary for the other end of the range). But the basic principle is the same. You'll symbolize each of your rasters with the desired color ramp, export/save that to a colorized raster, then merge/blend the two colorized rasters together to get your final bivariate raster. There are different approaches to merge/blend as well, and some software gives more options than others. For example it could be a transparency blend or an additive color blend.


There's an example specific method at this question using gdal.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...