def writeColorMapInfo(colormapPath, lutFilePath, demPath, outputPath): """Writes a file containing the color map information""" colormapPercentiles = [] numColorSteps = IrgFileFunctions.getFileLineCount(lutFilePath) for i in range(0,numColorSteps): # This loop generates the percentage values from the color profile we are using colormapPercentiles.append(i / float(numColorSteps-1)) # Get the min and max elevation of the DEM elevationBounds = IrgGeoFunctions.getImageStats(demPath) # Get elevation values for each percentile colormapPercentileValues = IrgMathFunctions.getPercentileValues(elevationBounds[0][0], elevationBounds[0][1], colormapPercentiles) # Now write out a version of the LUT file with values added inputFile = open(lutFilePath, 'r') outputFile = open(outputPath, 'w') # Add a header line to the output file outputFile.write('Percent of range, R, G, B, Elevation (meters above datum)\n') # Write a copy of the input file with the elevation values appended to each line for (line, value) in zip(inputFile, colormapPercentileValues): newLine = line[:-1] + ', ' + str(round(value,2)) + '\n' outputFile.write(newLine) inputFile.close() outputFile.close()