def getColorMapAsContinuousSLD(self, nodata=-9999):
        """
        Return the mapped color ramp as a
        :rtype: str
        """
        colorMap = ET.Element('ColorMap', type='interval')

        # Add a line for the no-data values (nv)
        ET.SubElement(colorMap, 'ColorMapEntry', color='#000000', quantity=str(nodata), label='NoData', opacity='0.0')

        def get_label_formatter(value):
            label_tag="{label:.0f}"
            if abs(value) < 0.01 and value != 0:
                label_tag = "{label:.2E}"
            elif abs(value) < 10:
                label_tag="{label:.2f}"
            elif abs(value) < 99:
                label_tag="{label:.1f}"
            return label_tag

        if self.min != self.max and self.slope > 0:
            for rampIndex in range(len(self.colorRamp)):
                valueForIndex = (rampIndex - self.intercept) / self.slope
                red, green, blue = self.colorRamp[rampIndex]
                hexRGB = '#%02X%02X%02X' % (red,
                                            green,
                                            blue)

                label_tag = get_label_formatter(valueForIndex)
                ET.SubElement(colorMap, 'ColorMapEntry', color=hexRGB,
                              quantity=str(valueForIndex),
                              label=label_tag.format(label=valueForIndex),
                              opacity=str(self.alpha))
        else:
            valueForIndex = self.max
            red, green, blue = self.colorRamp[0]
            hexRGB = '#%02X%02X%02X' % (red,
                                        green,
                                        blue)
            label_tag = get_label_formatter(valueForIndex)
            ET.SubElement(colorMap, 'ColorMapEntry', color=hexRGB,
                          quantity=str(valueForIndex),
                          label=label_tag.format(label=valueForIndex),
                          opacity=str(self.alpha))


        return ET.tostring(colorMap)
def getColorMapAsContinuousSLD ( self , nodata = - 9999 ) : colorMap = ET . Element ( 'ColorMap' , type = 'interval' ) ET . SubElement ( colorMap , 'ColorMapEntry' , color = '#000000' , quantity = str ( nodata ) , label = 'NoData' , opacity = '0.0' ) def get_label_formatter ( value ) : label_tag = "{label:.0f}" if abs ( value ) < 0.01 and value != 0 : label_tag = "{label:.2E}" elif abs ( value ) < 10 : label_tag = "{label:.2f}" elif abs ( value ) < 99 : label_tag = "{label:.1f}" return label_tag if self . min != self . max and self . slope > 0 : for rampIndex in range ( len ( self . colorRamp ) ) : valueForIndex = ( rampIndex - self . intercept ) / self . slope red , green , blue = self . colorRamp [ rampIndex ] hexRGB = '#%02X%02X%02X' % ( red , green , blue ) label_tag = get_label_formatter ( valueForIndex ) ET . SubElement ( colorMap , 'ColorMapEntry' , color = hexRGB , quantity = str ( valueForIndex ) , label = label_tag . format ( label = valueForIndex ) , opacity = str ( self . alpha ) ) else : valueForIndex = self . max red , green , blue = self . colorRamp [ 0 ] hexRGB = '#%02X%02X%02X' % ( red , green , blue ) label_tag = get_label_formatter ( valueForIndex ) ET . SubElement ( colorMap , 'ColorMapEntry' , color = hexRGB , quantity = str ( valueForIndex ) , label = label_tag . format ( label = valueForIndex ) , opacity = str ( self . alpha ) ) return ET . tostring ( colorMap )
Return the mapped color ramp as a
        :rtype: str