geodesign / django-raster

Django-raster allows you to create tiled map services (TMS) and raster map algebra end points for web maps. It is Python-based, and requires GeoDjango with a PostGIS backend.
BSD 3-Clause "New" or "Revised" License
96 stars 39 forks source link

Continuous colormaps - exact range boundary values not displayed #55

Open sebbelese opened 3 years ago

sebbelese commented 3 years ago

Hi,

Thanks for developing this nice software!

I noticed that the display of rasters with a continuous colormap was not including values exactly at the boundaries of the raster data range. This can be an issue for e.g. rasters having a lot of zeros as lower limit. If this is a bug, it can be fixed by modifying utils.py line 82 from:

        # Compute alpha channel from mask if available.
        if numpy.ma.is_masked(dat):
            alpha = 255 * numpy.logical_not(dat.mask) * (norm >= 0) * (norm <= 1)
        else:
            alpha = 255 * (norm > 0) * (norm < 1)

to

        # Compute alpha channel from mask if available.
        if numpy.ma.is_masked(dat):
            alpha = 255 * numpy.logical_not(dat.mask) * (norm >= 0) * (norm <= 1)
        else:
            alpha = 255 * (norm >= 0) * (norm <= 1)    #Just changed this line

Sorry for not making a proper merge request, but it is just a small change.