code: def mapColorRampToValues(cls, colorRamp, minValue, maxValue, alpha=1.0):
          
          minRampIndex = 0  # Always zero
          maxRampIndex = float(len(colorRamp) - 1)  # Map color ramp indices to values using equation of a line
  
          # Resulting equation will be:
          # rampIndex = slope * value + intercept
          if minValue != maxValue:
              slope = (maxRampIndex - minRampIndex) / (maxValue - minValue)
              intercept = maxRampIndex - (slope * maxValue)
          else:
              slope = 0
              intercept = minRampIndex
  
          # Return color ramp, slope, and intercept to interpolate by value
          mappedColorRamp = MappedColorRamp(colorRamp=colorRamp,
                                            slope=slope,
                                            intercept=intercept,
                                            min=minValue,
                                            max=maxValue,
                                            alpha=alpha)
  
          return mappedColorRamp
docs: Creates color ramp based on min and max values of all the raster pixels from all rasters. If pixel value is one
          of the no data values it will be excluded in the color ramp interpolation. Returns colorRamp, slope, intercept
  
          :param colorRamp: A list of RGB tuples representing a color ramp (e.g.: results of either generate color ramp method)
          :param minValue: Minimum value of range of values to map to color ramp
          :param maxValue: Maximum value of range of values to map to color ramp
          :param alpha: Decimal representing transparency (e.g.: 0.8)
  
          :rtype : MappedColorRamp