How the map is colorized is only a matter of defining the limits and colors in the style. So, if we want to translate statistical information into colors, we just need to associate the values that we want with a sequence of colors.
First, let's try it with the quartiles:
if __name__ == '__main__':block:
if __name__ == '__main__': dem = RasterData('output/dem.tif') shaded = RasterData('output/shaded.png') limits = [dem.stats['Q1'], dem.stats['Q3'], dem.stats['Maximum']] colors = ["#fc8d59", "#ffffbf", "#91cf60"] dem.colorize(limits, colors).write_image('output/stats.png') dem.alpha_blend(shaded).write_image('output/shaded_stats.png')