I am generating 2D statistical maps and would like to also generate and save the image colormaps. The mean-size image has a data type of float32. The following example modified from online sources:
with rasterio.open(name,'w',**profile) as dst:
dst.write(data.astype(np.float32), 1)
dst.write_colormap(
1, {
0: (255, 0, 0, 255),
255: (0, 0, 255, 255) })
cmap = dst.colormap(1)
print (cmp)
Does not work, and the call to colormap(1) returns a NULL table and terminates the program.
Changing the data type to uint8 or uint16, it works after a fashion, but I have been unable to find examples on how to change the color tables and maps for floating point and integer data types.
Could someone provide a snippet that shows how to generate different colormaps, colorinterps and/or color pallets for floating point images? While I am currently using rasterio, I can also convert this GDAL if someone can post a solution.