[QGIS-Developer] Fwd: Jenks Raster Styling?

C Hamilton adenaculture at gmail.com
Fri Sep 16 11:43:17 PDT 2022


I am posting this email to the developers group because my current comments
are more developer related. I am contemplating writing a plugin to make up
for the lack of Natural Breaks (Jenks) not in QGIS raster styling. There is
a feature request already to have this added as a core capability, but it
is unfunded.

https://github.com/qgis/QGIS/issues/39746

I received a request for Jenks raster styling from a team that doesn't
really care whether they use QGIS or Arc. They really like the speed of
QGIS, but the manager gets the question of why doesn't QGIS have Jenks
raster styling because they need it and it is available in Arc. I have
queried some of our folks to see if it is possible to get this funded to be
developed in core QGIS, but that process is quite time consuming and
wouldn't happen anytime soon so my question for near term use is whether it
is worth doing a plugin for it or not. That is really based on the
difficulty of implementation. I'm not really supposed to be taking on new
QGIS plugin development, but if it doesn't take me too much time, then my
management probably won't complain too much.

I have been looking at the documentation for the QGIS classification
methods. I believe these contain all that is needed for doing the raster
classification. Am I correct?

QgsClassificationMethod
https://api.qgis.org/api/3.22/classQgsClassificationMethod.html

QgsClassificationJenks
https://api.qgis.org/api/3.22/classQgsClassificationJenks.html

It appears that you pass in a List of values and it outputs a list of the
ranges. I don't think this needs to be a sorted list. Hopefully that is
the case. I think I could use these classification routines for all of the
styles it supports and apply them to rasters. This seems to be the process:

1. From the input raster image copy all the pixel intensities to a List to
pass to either QgsClassificationMethod or QgsClassificationJenks.
2. The output of these classification methods is a list
of QgsClassificationRange.
3. I am guessing that once you get the output classification ranges you
would then map them to equal segments of the selected color ramp. You would
then add each range to a manual value, color and label.
4. For Interpolation it probably should be set to either Linear or
Discrete. I'm not exactly sure what Mode does and what setting it should be.

There may be a problem with large images and the large number of pixel
values. NODATA values would be skipped. If the imagery gets overly large
only decimated pixels would probably be the way to go. How would you
developers handle this if the image is large? I wouldn't want to create
such a large list to pass to the classification methods that it would crash
QGIS or cause problems.

Am I missing anything that could potentially be a problem?

Rather than a plugin, how much effort would it take for one of you core
QGIS developers to implement and add to QGIS?

Thanks,

Calvin

---------- Forwarded message ---------
With Graduated vector symbology there are various modes such as Equal
Count, Equal Interval, Logarithmic scale ,Natural Breaks (Jenks), Pretty
Breaks, and Standard Deviation to apply the graduated style to the vector
data.

With raster styling there are only "Interpolation" options Discrete, Linear
and Exact, and then the "Mode" of Continuous, Equal Interval, and Quantile.

Is it possible to implement similar styling methods such as Jenks in raster
as you have with vector? Can these styles at least be simulated in some way
with how QGIS is now?

Thanks,

Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220916/bcbc1589/attachment.htm>


More information about the QGIS-Developer mailing list