3

I have a dataset of land values which, for the full range, is say 125 to 250,000,000, i.e for a whole state. For the user, they will only be seeing on the map canvas, a small subset of this at any one time, i.e for a suburb. But they will want to get a full spectrum on the colour ramp in their area of interest, to tease out the slightest variation in the suburb.

The approach I have taken is to divide the full range into 10 and have pseudo range of 1 - 100% within that sym_rnge. The psuedo range therefore repeats (code below). This is OK, until you get to the edges, when the values shown go from 99% to the next upper set and revert to 1% 2% etc.

I am using the VIRIDIS in-built ramp which looks nice, but doesn't repeat back to the starting colour (below). Instead the user seems brownish, purple, dark purple, yellow! I can't find an in-built ramp which repeats back to the starting colour. Just using that would solve my problem. enter image description here

I looked at editing the code for the ramp, it is way too detailed I think to edit.

Is there a way to;

  • have a colour ramp which repeats
  • approach the problem from another angle?
set sym_rnge = 
case
        when dlrs_ha1 between 0 and 12500 then dlrs_ha1 / 125
        when dlrs_ha1 between 12500 and 62500 then dlrs_ha1 / 625
        when dlrs_ha1 between 62500 and 312500 then dlrs_ha1 / 3125
        when dlrs_ha1 between 312500 and 1562500 then dlrs_ha1 / 15625
        when dlrs_ha1 between 1562500 and 7812500 then dlrs_ha1 / 78125
        when dlrs_ha1 between 7812500 and 39062500 then dlrs_ha1 / 390625        
        when dlrs_ha1 between 39062500 and 195312500 then dlrs_ha1 / 1953125        
        when dlrs_ha1 between 195312500 and 976562500 then dlrs_ha1 / 9765625
        when dlrs_ha1 between 976562500 and 4882812500 then dlrs_ha1 / 48828125
        when dlrs_ha1 between 4882812500 and 24414062500 then dlrs_ha1 / 244140625
        else dlrs_ha1

EDIT

Ramp editor enter image description here

  • 1
    You can edit colour ramps as you wish to do. That said, I'd rather suggest you use categories in order to display your data, and maybe add the values as labels, visible only at certain scales. Or you could create data which shows the value per area. – Erik Jul 6 at 13:35
  • As far as I can see, the editing tool for colour ramps presumes you have two distinct colours at each end. I would be wanting colour one at the start (yellow), the other distinct colour in the middle (dark purple) and yellow at the end again. But the edit widget is not built with this in mind, only the two end points which are presumed to be dissimilar. – BJW Jul 6 at 22:21
  • 1
    OK, figured out more "stops" can be added to the editor, that gives the option of more than 2 colours – BJW Jul 6 at 22:36
5

I'm not sure what exactly you want to achieve and how users will see the map canvas: in QGIS? The same instance as yours or on another computer? Online? Howver, what you can do is the define the min/max values of your raster for the whole raster file or just for the current canvas. See the documentation:

Calculations of the min and max values of the bands are made based on the: Statistics extent: it can be Whole raster, Current canvas or Updated canvas. Updated canvas means that min/max values used for the rendering will change with the canvas extent (dynamic stretching). https://docs.qgis.org/3.10/en/docs/user_manual/working_with_raster/raster_properties.html#setting-the-min-and-max-values

With this method, you always use the automatically whole range of your color ramp for each screen, it does not depend on the actual value range - in any case, the lowest value displayed in your canvas will get the color on the left, the highest value the color on the right of your color ramp, even if you are zoomed in and the canvas shows only a small section of the overall spectrum of min/max values for the whole raster.

See the difference here on these two screenshots - a digital elevation model, exactely same extract and color ramp, just re-classified with Whole raster and Current canvas:

Whole Raster

Current Canvas

| improve this answer | |
  • Hello @babel thanks for the detailed answer. The style for the vector layer can be saved with the project and the project shared to other users. As for classifying from the current canvas, this feature works at one point in time. I would be wanting the range to be sensitive to the canvas, every time the user pans across the canvas. – BJW Jul 6 at 22:16
  • Yes, that's exactely what this does - every time you pan or zoom, the map canvas updates automatically and sets the min/max of the current cancas to the colors at the extreme of your ramp. The documentation states explicitely: "Updated canvas means that min/max values used for the rendering will change with the canvas extent (dynamic stretching)." If this is not what you are looking for, please give more details and examples (best with screenshots) of what you want to achieve. – babel Jul 6 at 22:25
  • Be sure to select Updated canvas for Statistics extent – babel Jul 6 at 22:34
1

Figured out you can add stops in the editor to give more control than just the two endpoints. The end result

endless colour ramp

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.