Skip to content

Instantly share code, notes, and snippets.

@promonad
Forked from scisco/colormap.txt
Created July 2, 2017 11:34
Show Gist options
  • Select an option

  • Save promonad/e6a522bd5586a56dbfea9a2cbc33091e to your computer and use it in GitHub Desktop.

Select an option

Save promonad/e6a522bd5586a56dbfea9a2cbc33091e to your computer and use it in GitHub Desktop.
NDVI script
# Jun 29 2016
# ---------------------------------------------
# Source: https://github.com/nedhorning/PhotoMonitoringPlugin/blob/master/downloads/luts/NDVIBlu2Red.lut
mode = 255
46 3 120
46 3 120
46 5 121
45 7 122
45 8 123
45 10 124
44 12 125
44 13 126
44 15 127
43 17 128
43 19 129
42 20 130
42 22 131
42 24 132
41 25 133
41 27 134
41 29 135
40 31 136
40 32 137
40 34 138
39 36 139
39 37 140
38 39 142
38 41 143
38 43 144
37 44 145
37 46 146
37 48 147
36 49 148
36 51 149
35 53 150
35 55 151
35 56 152
34 58 153
34 60 154
34 61 155
33 63 156
33 65 157
33 67 158
32 68 159
32 70 160
31 72 161
31 73 162
31 75 164
30 77 165
30 78 166
30 80 167
29 82 168
29 84 169
29 85 170
28 87 171
28 89 172
27 90 173
27 92 174
27 94 175
26 96 176
26 97 177
26 99 178
25 101 179
25 102 180
24 104 181
24 106 182
24 108 183
23 109 184
23 111 186
23 113 187
22 114 188
22 116 189
22 118 190
21 120 191
21 121 192
20 123 193
20 125 194
20 126 195
19 128 196
19 130 197
19 132 198
18 133 199
18 135 200
17 137 201
17 138 202
17 140 203
16 142 204
16 144 205
16 145 206
15 147 207
15 149 209
15 150 210
14 152 211
14 154 212
13 155 213
13 157 214
13 159 215
12 161 216
12 162 217
12 164 218
11 166 219
11 167 220
11 169 221
10 171 222
10 173 223
9 174 224
9 176 225
9 178 226
8 179 227
8 181 228
8 183 229
7 185 231
7 186 232
6 188 233
6 190 234
6 191 235
5 193 236
5 195 237
5 197 238
4 198 239
4 200 240
4 202 241
3 203 242
3 205 243
2 207 244
2 209 245
2 210 246
1 212 247
1 214 248
1 215 249
0 217 250
0 219 251
0 163 0
5 164 0
10 166 0
15 168 0
20 170 0
26 172 0
31 174 0
36 176 0
41 178 0
46 179 0
52 181 0
57 183 0
62 185 0
67 187 0
72 189 0
78 191 0
83 193 0
88 194 0
93 196 0
98 198 0
104 200 0
109 202 0
114 204 0
119 206 0
125 208 1
130 209 1
135 211 1
140 213 1
145 215 1
151 217 1
156 219 1
161 221 1
166 223 1
171 224 1
177 226 1
182 228 1
187 230 1
192 232 1
197 234 1
203 236 1
208 238 1
213 239 1
218 241 1
223 243 1
229 245 1
234 247 1
239 249 1
244 251 1
255 255 0
255 251 0
255 248 0
255 245 0
255 242 0
255 238 0
255 235 0
255 232 0
255 229 0
255 225 0
255 222 0
255 219 0
255 216 0
255 213 0
255 209 0
255 206 0
255 203 0
255 200 0
255 196 0
255 193 0
255 190 0
255 187 0
255 183 0
255 180 0
255 177 0
255 174 0
255 171 0
255 167 0
255 164 0
255 161 0
255 158 0
255 154 0
255 151 0
255 148 0
255 145 0
255 142 0
255 138 0
255 135 0
255 132 0
255 129 0
255 125 0
255 122 0
255 119 0
255 116 0
255 112 0
255 109 0
255 106 0
255 103 0
255 100 0
255 96 0
255 93 0
255 90 0
255 87 0
255 83 0
255 80 0
255 77 0
255 74 0
255 71 0
255 67 0
255 64 0
255 61 0
255 58 0
255 54 0
255 51 0
255 48 0
255 45 0
255 41 0
255 38 0
255 35 0
255 32 0
255 29 0
255 25 0
255 22 0
255 19 0
255 16 0
255 12 0
255 9 0
255 6 0
255 3 0
255 3 0
from satio.landsat8 import Landsat8
from satio.sentinel2 import Sentinel2
from satio.utils import color_map_reader
def main():
colormap = color_map_reader('colormap.txt')
# sentinel
f = [
'/images/S2A_tile_20160410_60UXB_0/B04.jp2',
'/images/S2A_tile_20160410_60UXB_0/B08.jp2',
]
scene = Sentinel2(f)
ndvi = scene.ndvi().select(['ndvi'])
ndvi = ndvi.reproject('epsg:3857').recast('uint8')
ndvi.save('ndvi_sentinel.tif', bands=['ndvi'], nodata=0, colormap=colormap)
# landsat
f = [
'/images/LC80390332016096LGN00_B4.TIF',
'/images/LC80390332016096LGN00_B5.TIF',
]
scene = Landsat8(f)
ndvi = scene.ndvi().select(['ndvi'])
ndvi = ndvi.reproject('epsg:3857').recast('uint8')
ndvi.save('ndvi_landsat.tif', bands=['ndvi'], nodata=0, colormap=colormap)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment