Skip to content

Instantly share code, notes, and snippets.

@jpoehnelt
Created July 28, 2016 22:39
Show Gist options
  • Save jpoehnelt/9898a28a742302074e7aa07cdf2b2978 to your computer and use it in GitHub Desktop.
Save jpoehnelt/9898a28a742302074e7aa07cdf2b2978 to your computer and use it in GitHub Desktop.
tif color table to colormap
color_table = """
0: 0,0,0,255
1: 0,0,0,255
2: 0,0,0,255
3: 0,0,0,255
4: 0,0,0,255
5: 0,0,0,255
6: 0,0,0,255
7: 0,0,0,255
8: 0,0,0,255
9: 0,0,0,255
10: 249,160,255,255
11: 198,99,198,255
12: 249,160,255,255
13: 249,150,198,255
14: 198,150,209,255
15: 249,99,255,255
16: 249,130,255,255
17: 198,130,229,255
18: 219,150,255,255
19: 0,0,0,255
20: 0,99,0,255
21: 0,249,0,255
22: 0,198,0,255
23: 0,150,0,255
24: 0,99,0,255
25: 0,51,0,255
26: 0,224,0,255
27: 0,124,0,255
28: 0,0,0,255
29: 0,0,0,255
30: 99,255,0,255
31: 181,198,0,255
32: 140,198,0,255
33: 99,255,0,255
34: 61,255,61,255
35: 0,0,0,255
36: 0,0,0,255
37: 0,0,0,255
38: 0,0,0,255
39: 0,0,0,255
40: 0,255,119,255
41: 0,255,61,255
42: 0,255,119,255
43: 0,0,0,255
44: 0,0,0,255
45: 0,0,0,255
46: 0,0,0,255
47: 0,0,0,255
48: 0,0,0,255
49: 0,0,0,255
50: 0,99,255,255
51: 0,99,255,255
52: 0,99,150,255
53: 0,150,255,255
54: 0,0,0,255
55: 0,0,0,255
56: 0,0,0,255
57: 0,0,0,255
58: 0,0,0,255
59: 0,0,0,255
60: 0,0,255,255
61: 0,0,160,255
62: 0,0,79,255
63: 0,0,255,255
64: 0,0,0,255
65: 0,0,0,255
66: 0,0,0,255
67: 0,0,0,255
68: 0,0,0,255
69: 0,0,0,255
70: 99,99,51,255
71: 99,130,51,255
72: 99,160,51,255
73: 79,79,119,255
74: 61,61,119,255
75: 99,99,51,255
76: 0,0,0,255
77: 0,0,0,255
78: 0,0,0,255
79: 0,0,0,255
80: 255,0,0,255
81: 255,0,0,255
82: 0,0,0,255
83: 0,0,0,255
84: 0,0,0,255
85: 0,0,0,255
86: 0,0,0,255
87: 0,0,0,255
88: 0,0,0,255
89: 0,0,0,255
90: 191,191,191,255
91: 191,191,150,255
92: 191,191,99,255
93: 191,191,191,255
94: 160,160,160,255
95: 150,150,99,255
96: 130,130,130,255
97: 0,0,0,255
98: 0,0,0,255
99: 0,0,0,255
100: 198,239,255,255
101: 198,239,255,255
102: 150,239,255,255
103: 0,0,0,255
104: 0,0,0,255
105: 0,0,0,255
106: 0,0,0,255
107: 0,0,0,255
108: 0,0,0,255
109: 0,0,0,255
110: 0,0,0,255
111: 0,0,0,255
112: 0,0,0,255
113: 0,0,0,255
114: 0,0,0,255
115: 0,0,0,255
116: 0,0,0,255
117: 0,0,0,255
118: 0,0,0,255
119: 0,0,0,255
120: 0,0,0,255
121: 0,0,0,255
122: 0,0,0,255
123: 0,0,0,255
124: 0,0,0,255
125: 0,0,0,255
126: 0,0,0,255
127: 0,0,0,255
128: 0,0,0,255
129: 0,0,0,255
130: 0,0,0,255
131: 0,0,0,255
132: 0,0,0,255
133: 0,0,0,255
134: 0,0,0,255
135: 0,0,0,255
136: 0,0,0,255
137: 0,0,0,255
138: 0,0,0,255
139: 0,0,0,255
140: 0,0,0,255
141: 0,0,0,255
142: 0,0,0,255
143: 0,0,0,255
144: 0,0,0,255
145: 0,0,0,255
146: 0,0,0,255
147: 0,0,0,255
148: 0,0,0,255
149: 0,0,0,255
150: 0,0,0,255
151: 0,0,0,255
152: 0,0,0,255
153: 0,0,0,255
154: 0,0,0,255
155: 0,0,0,255
156: 0,0,0,255
157: 0,0,0,255
158: 0,0,0,255
159: 0,0,0,255
160: 0,0,0,255
161: 0,0,0,255
162: 0,0,0,255
163: 0,0,0,255
164: 0,0,0,255
165: 0,0,0,255
166: 0,0,0,255
167: 0,0,0,255
168: 0,0,0,255
169: 0,0,0,255
170: 0,0,0,255
171: 0,0,0,255
172: 0,0,0,255
173: 0,0,0,255
174: 0,0,0,255
175: 0,0,0,255
176: 0,0,0,255
177: 0,0,0,255
178: 0,0,0,255
179: 0,0,0,255
180: 0,0,0,255
181: 0,0,0,255
182: 0,0,0,255
183: 0,0,0,255
184: 0,0,0,255
185: 0,0,0,255
186: 0,0,0,255
187: 0,0,0,255
188: 0,0,0,255
189: 0,0,0,255
190: 0,0,0,255
191: 0,0,0,255
192: 0,0,0,255
193: 0,0,0,255
194: 0,0,0,255
195: 0,0,0,255
196: 0,0,0,255
197: 0,0,0,255
198: 0,0,0,255
102: 150,239,255,255
199: 0,0,0,255
200: 0,0,0,255
201: 0,0,0,255
202: 0,0,0,255
203: 0,0,0,255
204: 0,0,0,255
205: 0,0,0,255
206: 0,0,0,255
207: 0,0,0,255
208: 0,0,0,255
209: 0,0,0,255
210: 0,0,0,255
211: 0,0,0,255
212: 0,0,0,255
213: 0,0,0,255
214: 0,0,0,255
215: 0,0,0,255
216: 0,0,0,255
217: 0,0,0,255
218: 0,0,0,255
219: 0,0,0,255
220: 0,0,0,255
221: 0,0,0,255
222: 0,0,0,255
223: 0,0,0,255
224: 0,0,0,255
225: 0,0,0,255
226: 0,0,0,255
227: 0,0,0,255
228: 0,0,0,255
229: 0,0,0,255
230: 0,0,0,255
231: 0,0,0,255
232: 0,0,0,255
233: 0,0,0,255
234: 0,0,0,255
235: 0,0,0,255
236: 0,0,0,255
237: 0,0,0,255
238: 0,0,0,255
239: 0,0,0,255
240: 0,0,0,255
241: 0,0,0,255
242: 0,0,0,255
243: 0,0,0,255
244: 0,0,0,255
245: 0,0,0,255
246: 0,0,0,255
247: 0,0,0,255
248: 0,0,0,255
249: 0,0,0,255
250: 0,0,0,255
251: 0,0,0,255
252: 0,0,0,255
253: 0,0,0,255
254: 0,0,0,255
255: 0,198,255,255"""
rows = [line.strip() for line in color_table.split("\n")[1:]]
for row in rows:
i, color = [s.strip() for s in row.split(':')]
color = "".join(['{:02x}'.format(int(c)) for c in color.split(',')[0:3]])
print("\"<ColorMapEntry color='#%s' quantity='%s' label='%s' />\" +" % (color, i, i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment