Код: Выделить всё
rgb2pct -n 50 -of GIF input.tif output.gif
Код: Выделить всё
rgb2pct -pct indexing.gif -of GIF input.tif output.gif
Код: Выделить всё
<ColorTable>
<Entry c1="0" c2="0" c3="0" c4="255"/>
<Entry c1="145" c2="78" c3="224" c4="255"/>
</ColorTable>
Код: Выделить всё
# QGIS Generated Color Map Export File
INTERPOLATION:EXACT
0,100,68,76,255,Color entry 1
1,188,180,56,255,Color entry 2
3,156,216,172,255,Color entry 3
6,72,192,188,255,Color entry 4
7,136,176,200,255,Color entry 5
Код: Выделить всё
import sys
QGisPalette = open(sys.argv[1], "r")
VRTPalette = open(sys.argv[2], "wt")
VRTPalette.write('<VRTDataset rasterXSize="640" rasterYSize="480">\n')
VRTPalette.write(' <VRTRasterBand dataType="Byte" band="1">\n')
VRTPalette.write(' <ColorTable>\n')
for line in QGisPalette.readlines():
if line[0].isdigit():
VRTPalette.write(' <Entry c1="'+str(line.split(',')[1])+'" c2="'+str(line.split(',')[2])+'" c3="'+str(line.split(',')[3])+'" c4="'+str(line.split(',')[4])+'"/>\n')
VRTPalette.write(' </ColorTable>\n')
VRTPalette.write(' </VRTRasterBand>\n')
VRTPalette.write('</VRTDataset>\n')
QGisPalette.close()
VRTPalette.close()
Может, конечно, и некрасиво получилось, зато работает
