-
Notifications
You must be signed in to change notification settings - Fork 0
/
viirs-modis.yaml
676 lines (639 loc) · 27.2 KB
/
viirs-modis.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
import:
# - https://mapzen.com/carto/walkabout-style/6/walkabout-style.zip
# - https://mapzen.com/carto/refill-style/9/refill-style.zip
- https://mapzen.com/carto/refill-style/9/refill-style.yaml
# - https://mapzen.com/carto/tron-style/5/themes/tron-icons.zip
# - https://mapzen.com/carto/refill-style/9/themes/color-zinc.zip
# - https://mapzen.com/carto/refill-style/9/themes/color-inverted.zip
# - https://mapzen.com/carto/refill-style/9/themes/color-inverted.yaml
- https://mapzen.com/carto/refill-style/9/themes/color-gray-gold.zip
# - https://mapzen.com/carto/refill-style/9/themes/color-gray-gold.yaml
# - https://mapzen.com/carto/refill-style/9/themes/label-11.zip
- https://mapzen.com/carto/refill-style/9/themes/detail-11.zip
- https://mapzen-assets.s3.amazonaws.com/resources/demo.yaml
- https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/plasma.yaml
- https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viridis.yaml
global:
# color_6: [0,0,1]
# color_5: [.8,0,.5]
# color_4: [1,0,0]
# color_3: [1,.5,0]
# color_2: [1,1,0]
# color_1: [.9,.9,.9]
date: |
function(feature){
var date = feature.ACQ_DATE
var time = feature.ACQ_TIME
var date = date.replace(/\//g, '-');
var hour = time.slice(0, 2)
var minute = time.slice(2, 4)
var date_string = date + 'T' + hour + ':' + minute + 'Z'
var d = new Date(date_string);
return d
}
local_time: |
function(){
var date = feature.ACQ_DATE
var time = feature.ACQ_TIME
var sat = feature.SATELLITE
switch(sat) {
case 'N':
sat = "VIIRS\nSuomi NPP"
break
case 'A':
sat = "MODIS\nAqua"
break
case 'T':
sat = "MODIS\nTerra"
break
}
var date = date.replace(/\//g, '-');
var hour = time.slice(0, 2)
var minute = time.slice(2, 4)
var date_string = date + 'T' + hour + ':' + minute + 'Z'
var d = new Date(date_string);
// return date
var options = { weekday: 'short', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' };
return d.toLocaleDateString('en-US', options) + '\n' + sat + '\n' + feature.CONFIDENCE
// return d.toDateString() + '\n' + d.getHours() + ':' + d.getMinutes()
}
viridis_color: |
function(hours,window,opacity){
var color_10 = global.viridis_plasma[0]
color_10.push(opacity)
var color_9 = global.viridis_plasma[30]
color_9.push(opacity)
var color_8 = global.viridis_plasma[60]
color_8.push(opacity)
var color_7 = global.viridis_plasma[90]
color_7.push(opacity)
var color_6 = global.viridis_plasma[120]
color_6.push(opacity)
var color_5 = global.viridis_plasma[150]
color_5.push(opacity)
var color_4 = global.viridis_plasma[180]
color_4.push(opacity)
var color_3 = global.viridis_plasma[225]
color_3.push(opacity)
var color_2 = global.viridis_plasma[250]
color_2.push(opacity)
var color_1 = [1,1,1,opacity]
var color_0 = [0,1,0,opacity]
if (hours > window*9){color = color_10}
if (hours < window*9){color = color_9}
if (hours < window*8){color = color_8}
if (hours < window*7){color = color_7}
if (hours < window*6){color = color_6}
if (hours < window*5){color = color_5}
if (hours < window*4){color = color_4}
if (hours < window*3){color = color_3}
if (hours < window*2){color = color_2}
if (hours < window){color = color_1}
return color
}
_viridis_color: |
function(hours,window){
if (hours > window*9){color = global.viridis_plasma[0]}
if (hours < window*9){color = global.viridis_plasma[30]}
if (hours < window*8){color = global.viridis_plasma[60]}
if (hours < window*7){color = global.viridis_plasma[90]}
if (hours < window*6){color = global.viridis_plasma[120]}
if (hours < window*5){color = global.viridis_plasma[150]}
if (hours < window*4){color = global.viridis_plasma[180]}
if (hours < window*3){color = global.viridis_plasma[225]}
if (hours < window*2){color = global.viridis_plasma[250]}
if (hours < window){color = [1,1,1]}
return color
}
modis_temperature: |
function(feature){
var temp = feature.BRIGHTNESS
var color
temp = (temp - 300)
temp = (temp / 270) * 64
if ($zoom > 12){
color = 'hsla(' + temp + ',100%,50%,0.7)'
}
else {
color = [0,0,0,0]
}
return color
}
window: 12 # hours per window
then: [2017,09,18,12] # date string, 0 is jan, 11 is dec
styles:
_text:
base: text
blend_order: 2
_text_high:
base: text
blend_order: 5
_points:
base: points
blend_order: 3
_lines:
base: lines
blend_order: 1
terrain:
base: polygons
lighting: false
raster: normal
shaders:
uniforms:
# u_envmap: https://mapzen-assets.s3.amazonaws.com/resources/viirs-375-napa/dark-terrain.jpeg
u_envmap: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/spheremap-refill-terrain-dark-2.jpeg
u_contrast: 2.
u_zoom_scale: 4.5
u_brightness_base: 0.5
u_brightness_scaler: 0.5
blocks:
global: |
// Simplified view-independent environment map
vec4 applyEnvmap (in sampler2D _tex, in vec3 _normal, in float scale) {
_normal.z *= scale;
return texture2D(_tex, .5*(normalize(_normal).xy + 1.));
}
color: |
// turn terrain exaggeration up/down
// fade out spheremap normals with a function
float scale1 = 20./(u_map_position.z) + 1.5;
float m = u_zoom_scale * (u_map_position.z - 0.28) * exp(u_map_position.z * -.29);
m = clamp(m, 0., 1.5);
color = applyEnvmap(u_envmap, normal, 1./scale1);
// apply contrast and brightness
float contrast = m;
color.rgb = ((color.rgb - 0.9) * max(contrast, 0.)) + 0.5;
float brightness = u_brightness_base - m * u_brightness_scaler;
color.rgb += brightness/2.;
// apply layer color
color *= v_color;
sources:
mapzen:
# type: TopoJSON
# prod
rasters: [normals]
tile_size: 512
# max_zoom: 16
normals: # normals
type: Raster
# prod
url: https://tile.mapzen.com/mapzen/terrain/v1/512/normal/{z}/{x}/{y}.png
url_params:
api_key: global.sdk_mapzen_api_key
tile_size: 512
max_zoom: 14
viirs_fires:
type: GeoJSON
url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viirs_24_2017_10_24.geojson
modis_fires:
type: GeoJSON
url: https://s3.amazonaws.com/active-fire-data/modis_latest.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/modis_7d_2017_10_18.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/modis_7d_2017_10_17.geojson
modis_fires_10_14:
type: GeoJSON
url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/modis_7d_2017_10_14.geojson
active_perimeters:
type: GeoJSON
url: https://s3.amazonaws.com/active-fire-data/usgs_latest.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/active_perimeters_dd83_2017_10_18.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/active_perimeters_dd83_2017_10_16.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/active_perimeters_2017_10_11_1117.geojson
generate_label_centroids: true
viirs_7d:
type: GeoJSON
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viirs_7_2017_10_19.geojson
url: https://s3.amazonaws.com/active-fire-data/viirs_latest.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viirs_7_2017_10_18.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viirs_7_2017_10_16_0942.geojson // last 7 day dataset with Sun/Mon fire start
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/modis_7d_2017_10_15_1000.geojson
# url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viirs_7_2017_10_14_2000.geojson
napa_sonoma_first_days:
type: GeoJSON
url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/viirs_7_2017_10_16_0942.geojson # last 7 day dataset with Sun/Mon fire start
nyc:
type: GeoJSON
url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/sonoma_napa_fire_to_scale.geojson
redwood:
type: GeoJSON
url: https://s3.amazonaws.com/mapzen-assets/resources/viirs-375-napa/redwood_fire.geojson
sonoma:
type: GeoJSON
url: https://whosonfirst.mapzen.com/data/102/081/671/102081671.geojson
napa:
type: GeoJSON
url: https://whosonfirst.mapzen.com/data/102/085/383/102085383.geojson
layers:
_sonoma:
enabled: false
data: { source: sonoma}
draw:
lines:
color: red
order: 1000
width: 2px
_napa:
enabled: false
data: { source: napa}
draw:
lines:
color: blue
order: 1000
width: 2px
landuse:
enabled: false
earth:
data: { source: mapzen}
draw:
terrain:
order: function() { return feature.sort_rank || 0; }
color: [1.0, 1.0, 1.0]
text-blend-order:
text_source: global.ux_language_text_source
lines:
visible: false
_sonoma_napa_fire_first_day:
enabled: false
data: { source: napa_sonoma_first_days}
filter: {ACQ_DATE: '2017/10/09'}
draw:
_points:
size: [[10,5px],[13,20px],[14,45px],[15,100px],[17,200px]]
collide: false
color: |
function() {
var opacity
var color = global.plasma_10
if ($zoom < 8){opacity = 0.4}
else if ($zoom > 12) {opacity = 0.4}
else if ($zoom > 7) {opacity = 0.3}
// var color_8 = [.1,0,1,.25]
color.push(opacity)
return color
}
outline:
# # color: red
width: 1.5px
# color: [1,1,1,0.5]
color: |
function(){
if ($zoom > 12){
var color = global.plasma_20
var opacity = 0.9
color.push(opacity)
}
}
labels:
filter: {$zoom: {min: 15}}
draw:
# _points:
text:
style: _text
optional: false
collide: false
# text_source: function(){return feature.Name}
# text_source: BRIGHT_TI4
text_wrap: 30
text_source: |
function(){
var date = feature.ACQ_DATE
var time = feature.ACQ_TIME
var date = date.replace(/\//g, '-');
var hour = time.slice(0, 2)
var minute = time.slice(2, 4)
var date_string = date + 'T' + hour + ':' + minute + 'Z'
var d = new Date(date_string);
// return date
var options = { weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' };
return d.toLocaleDateString('en-US', options)
// return d.toDateString() + '\n' + d.getHours() + ':' + d.getMinutes()
}
# text_source: function(){return feature.ACQ_TIME +'\n'+ feature.ACQ_DATE}
font:
style: bold
size: 10px
fill: black
stroke:
color: white
width: 3px
_viirs_7d:
# enabled: false
data: { source: viirs_7d }
# filter:
# confidence: nominal
# not: {confidence: low}
draw:
points:
# interactive: true
collide: false
# color: red
color: |
function() {
var data_date = global.date(feature)
var now = new Date() // for live data
// or set to a previous time/date, 0=jan, 11=dec!
// var now = new Date(2017,09,09)
var hours = Math.abs(now - data_date) / 36e5
var window = global.window // hours per color
var opacity
if ($zoom < 8){opacity = 0.2 }
else if ($zoom > 12) {opacity = 0.4}
else if ($zoom > 7) {opacity = 0.6}
var color = global._viridis_color(hours,window)
color.push(opacity)
return color
}
size: [[10,5px],[13,20px],[14,45px],[15,100px],[17,200px]]
# size: function(){ return 375 * $meters_per_pixel }
# size: function() { return 375/$meters_per_pixel }
outline:
# # color: red
width: 1px
color: |
function() {
var data_date = global.date(feature)
var now = new Date() // for live data
// or set to a previous time/date, 0=jan, 11=dec!
// var now = new Date(2017,09,09)
var hours = Math.abs(now - data_date) / 36e5
var window = 12// global.window // hours per color
var opacity = 0.9
// if ($zoom < 8){opacity = 0.2 }
// else if ($zoom > 12) {opacity = 0.3}
// else if ($zoom > 7) {opacity = 0.6}
var color = global._viridis_color(hours,window)
color.push(opacity)
return color
}
labels:
filter: {$zoom: {min: 16}}
draw:
# _points:
text:
style: _text
# optional: false
collide: false
# text_source: function(){return feature.Name}
# text_source: BRIGHT_TI4
text_wrap: 12
text_source: global.local_time
# text_source: |
# function(){
# var date = feature.ACQ_DATE
# var time = feature.ACQ_TIME
# var date = date.replace(/\//g, '-');
# var hour = time.slice(0, 2)
# var minute = time.slice(2, 4)
# var date_string = date + 'T' + hour + ':' + minute + 'Z'
# var d = new Date(date_string);
# // return date
# var options = { weekday: 'short', month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit'};
# return d.toLocaleDateString('en-US', options) + ' (VIIRS)\n' + feature.CONFIDENCE
# // return d.toDateString() + '\n' + d.getHours() + ':' + d.getMinutes()
# }
# text_source: function(){return feature.ACQ_TIME +'\n'+ feature.ACQ_DATE}
font:
style: bold
size: 10px
fill: lightgrey
stroke:
color: black
width: 2px
_viirs_scale:
enabled: false
# data: { source: viirs_fires}
data: { source: nyc }
filter: {ACQ_DATE: '2017/10/09'}
draw:
points:
# interactive: true
collide: false
# color: red
color: |
function() {
var opacity
if ($zoom < 8){opacity = '0.3' }
else if ($zoom > 12) {opacity = '0.3'}
else if ($zoom > 7) {opacity = '0.8'}
var temp = feature.BRIGHT_TI4
// temp = temp/400
temp = temp - 315
// return [temp,0.2,0]
return 'hsla(' + temp + ',100%,50%,' + opacity + ')'
}
# size: [[10,5px],[14,15px],[18,375m]]
size: [[10,5px],[13,23px],[14,45px],[15,100m],[17,300m]]
outline:
# color: red
color: |
function(){
var opacity = 0.8
var temp = feature.BRIGHT_TI4
temp = temp - 315
// return 'hsla(' + temp + ',100%,50%,' + opacity + ')'
// return [temp,0.2,0]
if ((feature.ACQ_DATE == '2017/10/09') && ($zoom > 9)){
return [.9,.9,.9,0.4]}
if ($zoom > 12){
return 'hsla(' + temp + ',100%,50%,' + opacity + ')'
} else {
return [0,0,0,0]}
}
width: 1.5px
# width: 375 m
# width: |
# function(){
# return '375m'
# }
labels:
filter: {$zoom: {min: 15}}
draw:
# _points:
text:
style: _text
optional: false
collide: false
# text_source: function(){return feature.Name}
# text_source: BRIGHT_TI4
text_source: ACQ_TIME
font:
style: bold
size: 10px
fill: black
stroke:
color: white
width: 3px
_modis_fires_9_oct:
enabled: false
data: { source: modis_fires_10_14}
filter:
any:
- ACQ_DATE: 2017/10/09
- ACQ_DATE: 2017/10/10
# first day time ranges, for animation
# filter: {ACQ_TIME: '0630'} # 2017/10/09
# filter: {ACQ_TIME: '1045'} # 2017/10/09
# filter: {ACQ_TIME: '1830'} # 2017/10/09
# filter: {ACQ_TIME: '2145'} # 2017/10/09
# filter: {ACQ_TIME: '0535'} # 2017/10/10
# filter: {ACQ_TIME: '0950'} # 2017/10/10
# filter: {ACQ_TIME: '1915'} # 2017/10/10
# filter: {ACQ_TIME: '2050'} # 2017/10/10
draw:
_points:
collide: false
size: [[9,5px],[11,30px],[12,40px],[18,140px]]
# color: [1,0,0,0.5]
color: |
function() {
var data_date = global.date(feature)
// var now = new Date() // for live data
// or set to a previous time/date, 0=jan, 11=dec!
var now = new Date(2017,09,09)
var hours = Math.abs(now - data_date) / 36e5
var window = 3 // hours
var opacity
// color_10.push(opacity)
if ($zoom < 8){opacity = 0.3 }
else if ($zoom > 12) {opacity = 0.3}
else if ($zoom > 7) {opacity = 0.7}
var color = global.viridis_color(hours,window,opacity)
color.push(opacity)
return color
}
outline:
width: 2px
# color: global.modis_temperature(feature)
color: |
function(){
// var opacity = .7
var temp = feature.BRIGHTNESS
temp = (temp - 300)
temp = (temp / 270) * 64
if ($zoom > 12){
return [1,1,1,0.5]
// return 'hsla(' + temp + ',100%,50%,0.7)'
}
else {
return [0,0,0,0]
}
}
# color: | # temperature
# function() {
# var temp = feature.BRIGHTNESS
# temp = (temp - 300)
# temp = (temp / 270) * 64
# // return [temp,0.2,0]
# return 'hsla(' + temp + ',100%,50%,0.6)'
# // temp = temp/400
# // return [temp,0,0]
# }
label:
filter: {$zoom:{min: 13}}
draw:
text:
style: _text_high
optional: true
collide: false
# text_source: function(){return feature.Name}
# text_source: BRIGHTNESS
text_source: global.local_time
font:
style: bold
size: 10px
fill: black
stroke:
color: white
width: 3px
_modis_latest:
# enabled: false
data: { source: modis_fires}
draw:
points:
collide: false
# size: 10px
size: [[9,10px],[11,30px],[12,40px],[18,140px]]
# color: [1,0,0,0.5]
color: |
function() {
var data_date = global.date(feature)
var now = new Date() // for live data
// or set to a previous time/date, 0=jan, 11=dec!
// var now = new Date(2017,09,09)
var hours = Math.abs(now - data_date) / 36e5
var window = global.window // hours per color
var opacity
if ($zoom < 8){opacity = 0.1 }
else if ($zoom > 12) {opacity = 0.3}
else if ($zoom > 7) {opacity = 0.6}
var color = global._viridis_color(hours,window)
color.push(opacity)
return color
}
outline:
width: 2px
# color: global.modis_temperature(feature)
color: |
function(){
// var opacity = .7
var temp = feature.BRIGHTNESS
temp = (temp - 300)
temp = (temp / 270) * 64
if ($zoom > 13){
return [1,1,1,0.5]
// return 'hsla(' + temp + ',100%,50%,0.7)'
}
else {
return [0,0,0,0]
}
}
# color: | # temperature
# function() {
# var temp = feature.BRIGHTNESS
# temp = (temp - 300)
# temp = (temp / 270) * 64
# // return [temp,0.2,0]
# return 'hsla(' + temp + ',100%,50%,0.6)'
# // temp = temp/400
# // return [temp,0,0]
# }
label:
filter: {$zoom:{min: 15}}
draw:
text:
style: _text_high
optional: true
collide: false
# text_source: function(){return feature.Name}
# text_source: BRIGHTNESS
text_source: global.local_time
font:
style: bold
size: 10px
fill: black
stroke:
color: white
width: 3px
perimeters:
data: {source: active_perimeters}
boundary:
draw:
lines:
# color: red
color: [1,0,0,0.7]
width: 1px
order: 2000
labels:
filter: {label_placement: true}
draw:
_text_high:
text_source: function(){ return feature.FIRENAME + " FIRE"}
font:
# transform: uppercase
transform: lowercase
style: bold
size: 10px
fill: [0,0,0,0.7]
stroke:
color: [1,1,1,0.8]
width: 3px