-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpart_one--google_earth_engine
1241 lines (1009 loc) · 37.4 KB
/
part_one--google_earth_engine
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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// John Polo
// Calculate mean of temperature for specified counties and date ranges.
// Counties:
// 'Camden'
// 'Pasquotank'
// 'Rutherford'
// 'Guilford'
// 'Wake'
//// Study areaas
var camdo = ee.FeatureCollection("TIGER/2016/Counties").filter(ee.Filter.eq('NAME', 'Camden')).geometry();
var pasdo = ee.FeatureCollection("TIGER/2016/Counties").filter(ee.Filter.eq('NAME', 'Pasquotank')).geometry();
var rudo = ee.FeatureCollection("TIGER/2016/Counties").filter(ee.Filter.eq('NAME', 'Rutherford')).geometry();
var gudo = ee.FeatureCollection("TIGER/2016/Counties").filter(ee.Filter.eq('NAME', 'Guilford')).geometry();
var wado = ee.FeatureCollection("TIGER/2016/Counties").filter(ee.Filter.eq('NAME', 'Wake')).geometry();
var nc1 = ee.FeatureCollection("TIGER/2018/States").filter(ee.Filter.eq('NAME', 'North Carolina'));
var loc1 = camdo.intersection(nc1);
var loc2 = pasdo.intersection(nc1);
var loc3 = rudo.intersection(nc1);
var loc4 = gudo.intersection(nc1);
var loc5 = wado.intersection(nc1);
var sbands = ['tmax', 'tmin', 'vp'];
//////// After setting up the geometries, the workflow is generally
//////// to use the geo. in a mapped clip() of an ImageCollection (I.C.). At the same
//////// time, select the appropriate bands. Then use the addmeans()
//////// fxn to map a new average temp. band to I.C. Then it might
//////// be necessary to use .mean() to get a mean of the bands in question.
//////// After that, filter [.gt() or .lt()]. Then a reducer. That gets
//////// a binary mask. Use that in over_Threshold and then use getStats()
//////// There are exports for tables and rasters.
// Created a different collection for each geographic region to keep them separate,
// otherwise a contiguous raster is created from N.Y. to FL.
// Calculate mean temp. from max. and min.
function addmean(image) {
var tmean = ee.Image().expression(
'(tmax + tmin) / 2', {
'tmin' : image.select('tmin'),
'tmax' : image.select('tmax'),
});
tmean = tmean.rename('tmean');
return image.addBands(tmean);
}
// To get one value that represents the mean through the years
// as well as across the region:
// 1) First get the mean of each pixel for each band
// 2) Then use reduce with mean
//////////////////////////////
//////////////////////////////
// Using mean from first five years as a threshold, create binary
// rasters that have days with MAX temp. over the threshold.
// Exports the binary rasters where I do more processing in R
// to determine how many days have MAX T over threshold.
// Calculate mean for selected month across multiple years like this:
var daymetmy = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2012-04-01','2016-09-01').filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
// Broke out the years to avoid having to separate them later
//////// 2012
var daymet1 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2012-04-01','2012-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
var daymet2 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2012-04-01','2012-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet3 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2012-04-01','2012-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet4 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2012-04-01','2012-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet5 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2012-04-01','2012-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////// 2013
var daymet12 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2013-04-01','2013-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
//print('87',daymet1);
var daymet13 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2013-04-01','2013-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet14 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2013-04-01','2013-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet15 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2013-04-01','2013-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet16 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2013-04-01','2013-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2014
var daymet19 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2014-04-01','2014-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
//print('87',daymet1);
var daymet20 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2014-04-01','2014-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet21 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2014-04-01','2014-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet22 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2014-04-01','2014-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet23 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2014-04-01','2014-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2015
var daymet26 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2015-04-01','2015-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
//print('87',daymet1);
var daymet27 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2015-04-01','2015-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet28 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2015-04-01','2015-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet29 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2015-04-01','2015-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet30 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2015-04-01','2015-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2016
var daymet33 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2016-04-01','2016-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
//print('87',daymet1);
var daymet34 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2016-04-01','2016-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet35 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2016-04-01','2016-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet36 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2016-04-01','2016-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet37 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2016-04-01','2016-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2017
var daymet40 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2017-04-01','2017-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
var daymet41 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2017-04-01','2017-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet42 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2017-04-01','2017-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet43 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2017-04-01','2017-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet44 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2017-04-01','2017-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2018
var daymet47 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2018-04-01','2018-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
var daymet48 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2018-04-01','2018-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet49 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2018-04-01','2018-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet50 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2018-04-01','2018-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet51 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2018-04-01','2018-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2019
var daymet54 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2019-04-01','2019-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
var daymet55 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2019-04-01','2019-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet56 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2019-04-01','2019-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet57 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2019-04-01','2019-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet58 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2019-04-01','2019-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2020
var daymet61 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2020-04-01','2020-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
var daymet62 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2020-04-01','2020-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet63 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2020-04-01','2020-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet64 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2020-04-01','2020-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet65 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2020-04-01','2020-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
//////2021
var daymet68 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2021-04-01','2021-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
//print('87',daymet1);
var daymet69 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2021-04-01','2021-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc2)});
var daymet70 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2021-04-01','2021-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc3)});
var daymet71 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2021-04-01','2021-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc4)});
var daymet72 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2021-04-01','2021-09-01')//.filter(ee.Filter.calendarRange(7, 7,'month'))
.select(sbands).map(function(im){return im.clip(loc5)});
var daymet1 = daymet1.map(addmean);
var daymet2 = daymet2.map(addmean);
var daymet3 = daymet3.map(addmean);
var daymet4 = daymet4.map(addmean);
var daymet5 = daymet5.map(addmean);
var daymet12 = daymet12.map(addmean);
var daymet13 = daymet13.map(addmean);
var daymet19 = daymet19.map(addmean);
var daymet20 = daymet20.map(addmean);
var daymet21 = daymet21.map(addmean);
var daymet22 = daymet22.map(addmean);
var daymet23 = daymet23.map(addmean);
var daymet26 = daymet26.map(addmean);
var daymet27 = daymet27.map(addmean);
var daymet28 = daymet28.map(addmean);
var daymet29 = daymet29.map(addmean);
var daymet30 = daymet30.map(addmean);
var daymet33 = daymet33.map(addmean);
var daymet34 = daymet34.map(addmean);
var daymet35 = daymet35.map(addmean);
var daymet36 = daymet36.map(addmean);
var daymet37 = daymet37.map(addmean);
var daymet40 = daymet41.map(addmean);
var daymet41 = daymet41.map(addmean);
var daymet42 = daymet42.map(addmean);
var daymet43 = daymet43.map(addmean);
var daymet44 = daymet44.map(addmean);
var daymet47 = daymet47.map(addmean);
var daymet48 = daymet48.map(addmean);
var daymet49 = daymet49.map(addmean);
var daymet50 = daymet50.map(addmean);
var daymet51 = daymet51.map(addmean);
var daymet54 = daymet54.map(addmean);
var daymet55 = daymet55.map(addmean);
var daymet56 = daymet56.map(addmean);
var daymet57 = daymet57.map(addmean);
var daymet58 = daymet58.map(addmean);
var daymet61 = daymet61.map(addmean);
var daymet62 = daymet62.map(addmean);
var daymet63 = daymet63.map(addmean);
var daymet64 = daymet64.map(addmean);
var daymet65 = daymet65.map(addmean);
var daymet68 = daymet68.map(addmean);
var daymet69 = daymet69.map(addmean);
var daymet70 = daymet70.map(addmean);
var daymet71 = daymet71.map(addmean);
var daymet72 = daymet72.map(addmean);
// Filter for a range of temperatures for each image
var p_day = function(image){
var tx1 = image.select('tmax');
var tx2 = tx1.updateMask(tx1.gt(10))
.updateMask(tx1.lt(26))
.gt(10).selfMask().rename('inf_range');
var tx3 = tx1.updateMask(tx1.gt(25))
.updateMask(tx1.lt(35))
.gt(25).selfMask().rename('nic_range');
return image.addBands([tx2,tx3]);
};
var daymet1 = daymet1.map(p_day);
var daymet2 = daymet2.map(p_day);
var daymet3 = daymet3.map(p_day);
var daymet4 = daymet4.map(p_day);
var daymet5 = daymet5.map(p_day);
var daymet12 = daymet12.map(p_day);
var daymet13 = daymet13.map(p_day);
var daymet14 = daymet14.map(p_day);
var daymet15 = daymet15.map(p_day);
var daymet16 = daymet16.map(p_day);
var daymet19 = daymet19.map(p_day);
var daymet20 = daymet20.map(p_day);
var daymet21 = daymet21.map(p_day);
var daymet22 = daymet22.map(p_day);
var daymet23 = daymet23.map(p_day);
var daymet26 = daymet26.map(p_day);
var daymet27 = daymet27.map(p_day);
var daymet28 = daymet28.map(p_day);
var daymet29 = daymet29.map(p_day);
var daymet30 = daymet30.map(p_day);
var daymet33 = daymet33.map(p_day);
var daymet34 = daymet34.map(p_day);
var daymet35 = daymet35.map(p_day);
var daymet36 = daymet36.map(p_day);
var daymet37 = daymet37.map(p_day);
var daymet40 = daymet40.map(p_day);
var daymet41 = daymet41.map(p_day);
var daymet42 = daymet42.map(p_day);
var daymet43 = daymet43.map(p_day);
var daymet44 = daymet44.map(p_day);
var daymet47 = daymet47.map(p_day);
var daymet48 = daymet48.map(p_day);
var daymet49 = daymet49.map(p_day);
var daymet50 = daymet50.map(p_day);
var daymet51 = daymet51.map(p_day);
var daymet54 = daymet54.map(p_day);
var daymet55 = daymet55.map(p_day);
var daymet56 = daymet56.map(p_day);
var daymet57 = daymet57.map(p_day);
var daymet58 = daymet58.map(p_day);
var daymet61 = daymet61.map(p_day);
var daymet62 = daymet62.map(p_day);
var daymet63 = daymet63.map(p_day);
var daymet64 = daymet64.map(p_day);
var daymet65 = daymet65.map(p_day);
var daymet68 = daymet68.map(p_day);
var daymet69 = daymet69.map(p_day);
var daymet70 = daymet70.map(p_day);
var daymet71 = daymet71.map(p_day);
var daymet72 = daymet72.map(p_day);
//// Use this for just getting a value. Need a raster? Scroll more.
// Then reduce with mean or count, etc.
var testmm1 = testm1.reduceRegion({
reducer: ee.Reducer.count,
geometry: loc1,
scale: 30,
maxPixels: 1e9
});
//The result is a Dictionary. Print it.
var testmm1 = testmm1.combine({loc: 'camden'});
Export.table.toDrive({ collection: ee.FeatureCollection([ee.Feature(null, testmm1)]),
descriptoion: 'suff 2019', //'camden_t_count_July_12',
folder: 'daymet_txn_hourly',
});
var testmm2 = testm2.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: loc2,
scale: 30,
maxPixels: 1e9
});
var testmm2 = testmm2.combine({loc: 'pasq'});
Export.table.toDrive({ collection: ee.FeatureCollection([ee.Feature(null, testmm2)]),
description: 'pasqu_t_count_July_12',
folder: 'daymet_txn_hourly',
});
var testmm3 = testm3.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: loc3,
scale: 30,
maxPixels: 1e9
});
var testmm3 = testmm3.combine({loc: 'ruth'});
Export.table.toDrive({ collection: ee.FeatureCollection([ee.Feature(null, testmm3)]),
description: 'ruth_t_count_July_12',
folder: 'daymet_txn_hourly',
});
var testmm4 = testm4.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: loc4,
scale: 30,
maxPixels: 1e9
});
//print('meandict4 Guilf', testmm4);
var testmm4 = testmm4.combine({loc: 'guil'});
Export.table.toDrive({ collection: ee.FeatureCollection([ee.Feature(null, testmm4)]),
description: 'guilf_t_count_July_12',
folder: 'daymet_txn_hourly',
});
var testmm5 = testm5.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: loc5,
scale: 30,
maxPixels: 1e9
});
//print('meandict5 Wake', testmm5);
var testmm5 = testmm5.combine({loc: 'wake'});
Export.table.toDrive({ collection: ee.FeatureCollection([ee.Feature(null, testmm5)]),
description: 'wake_t_count_July_12',
folder: 'daymet_txn_hourly',
});
//// This is for getting means of years 2017 - 2021
var daymetB1 = ee.ImageCollection("NASA/ORNL/DAYMET_V4")
.filterDate('2017-04-01','2021-07-01').filter(ee.Filter.calendarRange(4, 6,'month'))
.select(sbands).map(function(im){return im.clip(loc1)});
// Create a binary raster.This will make counts of days easier. Further processing in R.
var daysOverThreshold = function(image) {
var maxt = image.select('tmax');
var daynm1 = ee.String('over_T_');
var daynm = daynm1.cat(ee.Date(image.get('system:time_start')).format("YYYY-MM-dd"));
var daym = maxt.gt(ee.Number(testmm1.get('tmax'))).rename(daynm);
return image.addBands(daym);
};
// Reduce for a single value again
var getStats = function(img) {
var image = ee.Image(img);
var inm1 = ee.String('over_T');
var inm2 = inm1.cat(ee.Date(image.get('system:time_start')).format("YYYY-MM-dd"));
var reducers = ee.Reducer.count();
var stats = image.reduceRegion({
reducer: reducers,
geometry: loc1,
bestEffort: true,
});
return image.set(stats).rename(inm2);
}
// Process the data for later years to get the binary rasters that provide days over threshold:
// This will make counts of days easier. Further processing in R.
// var dotCa = daymetB1.map(daysOverThreshold);
// var dotCa = dotCa.select('over_T.*');
// var dotCa = dotCa.map(getStats);
// var dotoutCa = dotCa.toBands();
// Export.image.toDrive({ image: dotoutCa.toInt32(),
// description: 'camden_count',
// folder: 'daymet_txn_hourly',
// region: loc1,
// scale: 30,
// maxPixels: 1e13
// });
// Repeat as need for year/location
var getStats = function(img) {
var image = ee.Image(img);
//var inm1 = ee.String('over_T');
//var inm2 = inm1.cat(ee.Date(image.get('system:time_start')).format("YYYY-MM-dd"));
var reducers = ee.Reducer.max();
var stats = image.reduceRegion({
reducer: reducers,
geometry: loc1,
bestEffort: true,
});
return image.set(stats);//.rename(inm2);
};
var dotCa = daymet1.map(p_day);
var dotCa = dotCa.select(['inf_range','nic_range']);
var dotCa = dotCa.map(getStats);
var dotCa = dotCa.toBands();
Export.image.toDrive({ image: dotCa.toInt32(),
description: 'camden11_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,
scale: 30,
maxPixels: 1e13
});
var dotP = daymet2.map(p_day);
var dotP = dotP.select(['inf_range','nic_range']);
var dotP = dotP.map(getStats);
var dotoutP = dotP.toBands();
Export.image.toDrive({ image: dotoutP.toInt32(),
description: 'Pasq16_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc2,
scale: 30,
maxPixels: 1e13
});
var dotR = daymet3.map(p_day);
var dotR = dotR.select(['inf_range','nic_range']);
var dotR = dotR.map(getStats);
var dotoutR = dotR.toBands();
Export.image.toDrive({ image: dotoutR.toInt32(),
description: 'Ruther12_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc3,
scale: 30,
maxPixels: 1e13,
});
var dotG = daymet4.map(p_day);
var dotG = dotG.select(['inf_range','nic_range']);
var dotG = dotG.map(getStats);
var dotoutG = dotG.toBands();
Export.image.toDrive({ image: dotoutG.toInt32(),
description: 'Guil12_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc4,
scale: 30,
maxPixels: 1e13,
});
var dotW = daymet5.map(p_day);
var dotW = dotW.select(['inf_range','nic_range']);
var dotW = dotW.map(getStats);
var dotoutW = dotW.toBands();
Export.image.toDrive({ image: dotoutW.toInt32(),
description: 'Wake12_tmax_daycounts',
folder:'daymet_txn_hourly',
region: loc5,
scale: 30,
maxPixels: 1e13
});
// //2013
var dotCa3 = daymet12.map(p_day);
var dotCa3 = dotCa3.select(['inf_range','nic_range']);//select('over_T.*');
var dotCa3 = dotCa3.map(getStats);
var dotCa3 = dotCa3.toBands();
print('884 dotc', dotCa3);
Export.image.toDrive({ image: dotCa3.toInt32(),
description: 'camden16_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,
scale: 30,
maxPixels: 1e13
});
var dotP3 = daymet13.map(p_day);
var dotP3 = dotP3.select(['inf_range','nic_range']);
var dotP3 = dotP3.map(getStats);
var dotoutP3 = dotP3.toBands();
Export.image.toDrive({ image: dotoutP3.toInt32(),
description: 'Pasq17_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc2,
scale: 30,
maxPixels: 1e13
});
var dotR3 = daymet14.map(p_day);
var dotR3 = dotR3.select(['inf_range','nic_range']);
var dotR3 = dotR3.map(getStats);
var dotoutR3 = dotR3.toBands();
Export.image.toDrive({ image: dotoutR3.toInt32(),
description: 'Ruther18_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc3,
scale: 30,
maxPixels: 1e13,
});
var dotG3 = daymet15.map(p_day);
var dotG3 = dotG3.select(['inf_range','nic_range']);
var dotG3 = dotG3.map(getStats);
var dotoutG3 = dotG3.toBands();
Export.image.toDrive({ image: dotoutG3.toInt32(),
description: 'Guil13_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc4,
scale: 30,
maxPixels: 1e13,
});
var dotW3 = daymet16.map(p_day);
var dotW3 = dotW3.select(['inf_range','nic_range']);
var dotW3 = dotW3.map(getStats);
var dotoutW3 = dotW3.toBands();
Export.image.toDrive({ image: dotoutW3.toInt32(),
description: 'Wake13_tmax_daycounts',
folder:'daymet_txn_hourly',
region: loc5,
scale: 30,
maxPixels: 1e13
});
// //2014
var dotCa4 = daymet19.map(p_day);
var dotCa4 = dotCa4.select(['inf_range','nic_range']);//select('over_T.*');
var dotCa4 = dotCa4.map(getStats);
var dotCa4 = dotCa4.toBands();
print('884 dotc', dotCa);
Export.image.toDrive({ image: dotCa4.toInt32(),
description: 'camden14_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,
scale: 30,
maxPixels: 1e13
});
var dotP4 = daymet20.map(p_day);
var dotP4 = dotP4.select(['inf_range','nic_range']);
var dotP4 = dotP4.map(getStats);
var dotoutP4 = dotP4.toBands();
Export.image.toDrive({ image: dotoutP4.toInt32(),
description: 'Pasq14_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc2,
scale: 30,
maxPixels: 1e13
});
var dotR4 = daymet21.map(p_day);
var dotR4 = dotR4.select(['inf_range','nic_range']);
var dotR4 = dotR4.map(getStats);
var dotoutR4 = dotR4.toBands();
Export.image.toDrive({ image: dotoutR4.toInt32(),
description: 'Ruther14_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc3,
scale: 30,
maxPixels: 1e13,
});
var dotG4 = daymet22.map(p_day);
var dotG4 = dotG4.select(['inf_range','nic_range']);
var dotG4 = dotG4.map(getStats);
var dotoutG4 = dotG4.toBands();
Export.image.toDrive({ image: dotoutG4.toInt32(),
description: 'Guil14_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc4,
scale: 30,
maxPixels: 1e13,
});
var dotW4 = daymet23.map(p_day);
var dotW4 = dotW4.select(['inf_range','nic_range']);
var dotW4 = dotW4.map(getStats);
var dotoutW4 = dotW4.toBands();
Export.image.toDrive({ image: dotoutW4.toInt32(),
description: 'Wake14_tmax_daycounts',
folder:'daymet_txn_hourly',
region: loc5,
scale: 30,
maxPixels: 1e13
});
// //2015
var dotCa5 = daymet26.map(p_day);
var dotCa5 = dotCa5.select(['inf_range','nic_range']);//select('over_T.*');
var dotCa5 = dotCa5.map(getStats);
var dotCa5 = dotCa5.toBands();
print('884 dotc', dotCa);
Export.image.toDrive({ image: dotCa5.toInt32(),
description: 'camden15_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,
scale: 30,
maxPixels: 1e13
});
var dotP5 = daymet27.map(p_day);
var dotP5 = dotP5.select(['inf_range','nic_range']);
var dotP5 = dotP5.map(getStats);
var dotoutP5 = dotP5.toBands();
Export.image.toDrive({ image: dotoutP5.toInt32(),
description: 'Pasq15_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc2,
scale: 30,
maxPixels: 1e13
});
var dotR5 = daymet28.map(p_day);
var dotR5 = dotR5.select(['inf_range','nic_range']);
var dotR5 = dotR5.map(getStats);
var dotoutR5 = dotR5.toBands();
Export.image.toDrive({ image: dotoutR5.toInt32(),
description: 'Ruther15_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc3,
scale: 30,
maxPixels: 1e13,
});
var dotG5 = daymet29.map(p_day);
var dotG5 = dotG5.select(['inf_range','nic_range']);
var dotG5 = dotG5.map(getStats);
var dotoutG5 = dotG5.toBands();
Export.image.toDrive({ image: dotoutG5.toInt32(),
description: 'Guil15_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc4,
scale: 30,
maxPixels: 1e13,
});
var dotW5 = daymet30.map(p_day);
var dotW5 = dotW5.select(['inf_range','nic_range']);
var dotW5 = dotW5.map(getStats);
var dotoutW5 = dotW5.toBands();
Export.image.toDrive({ image: dotoutW5.toInt32(),
description: 'Wake15_tmax_daycounts',
folder:'daymet_txn_hourly',
region: loc5,
scale: 30,
maxPixels: 1e13
});
// //2016
var dotCa6 = daymet33.map(p_day);
var dotCa6 = dotCa6.select(['inf_range','nic_range']);//select('over_T.*');
var dotCa6 = dotCa6.map(getStats);
var dotCa6 = dotCa6.toBands();
print('884 dotc', dotCa);
Export.image.toDrive({ image: dotCa6.toInt32(),
description: 'camden16_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,
scale: 30,
maxPixels: 1e13
});
var dotP6 = daymet34.map(p_day);
var dotP6 = dotP6.select(['inf_range','nic_range']);
var dotP6 = dotP6.map(getStats);
var dotoutP6 = dotP6.toBands();
Export.image.toDrive({ image: dotoutP6.toInt32(),
description: 'Pasq16_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc2,
scale: 30,
maxPixels: 1e13
});
var dotR6 = daymet35.map(p_day);
var dotR6 = dotR6.select(['inf_range','nic_range']);
var dotR6 = dotR6.map(getStats);
var dotoutR6 = dotR6.toBands();
Export.image.toDrive({ image: dotoutR6.toInt32(),
description: 'Ruther16_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc3,
scale: 30,
maxPixels: 1e13,
});
var dotG6 = daymet36.map(p_day);
var dotG6 = dotG6.select(['inf_range','nic_range']);
var dotG6 = dotG6.map(getStats);
var dotoutG6 = dotG6.toBands();
Export.image.toDrive({ image: dotoutG6.toInt32(),
description: 'Guil16_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc4,
scale: 30,
maxPixels: 1e13,
});
var dotW6 = daymet37.map(p_day);
var dotW6 = dotW6.select(['inf_range','nic_range']);
var dotW6 = dotW6.map(getStats);
var dotoutW6 = dotW6.toBands();
Export.image.toDrive({ image: dotoutW6.toInt32(),
description: 'Wake16_tmax_daycounts',
folder:'daymet_txn_hourly',
region: loc5,
scale: 30,
maxPixels: 1e13
});
// //2017
var dotCa7 = daymet40.map(p_day);
var dotCa7 = dotCa7.select(['inf_range','nic_range']);//select('over_T.*');
var dotCa7 = dotCa7.map(getStats);
var dotCa7 = dotCa7.toBands();
print('884 dotc', dotCa);
Export.image.toDrive({ image: dotCa7.toInt32(),
description: 'camden17_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,
scale: 30,
maxPixels: 1e13
});
var dotP7 = daymet41.map(p_day);
var dotP7 = dotP7.select(['inf_range','nic_range']);
var dotP7 = dotP7.map(getStats);
var dotoutP7 = dotP7.toBands();
Export.image.toDrive({ image: dotoutP7.toInt32(),
description: 'Pasq17_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc2,
scale: 30,
maxPixels: 1e13
});
var dotR7 = daymet42.map(p_day);
var dotR7 = dotR7.select(['inf_range','nic_range']);
var dotR7 = dotR7.map(getStats);
var dotoutR7 = dotR7.toBands();
Export.image.toDrive({ image: dotoutR7.toInt32(),
description: 'Ruther17_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc3,
scale: 30,
maxPixels: 1e13,
});
var dotG7 = daymet43.map(p_day);
var dotG7 = dotG7.select(['inf_range','nic_range']);
var dotG7 = dotG7.map(getStats);
var dotoutG7 = dotG7.toBands();
Export.image.toDrive({ image: dotoutG7.toInt32(),
description: 'Guil17_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc4,
scale: 30,
maxPixels: 1e13,
});
var dotW7 = daymet44.map(p_day);
var dotW7 = dotW7.select(['inf_range','nic_range']);
var dotW7 = dotW7.map(getStats);
var dotoutW7 = dotW7.toBands();
Export.image.toDrive({ image: dotoutW7.toInt32(),
description: 'Wake17_tmax_daycounts',
folder:'daymet_txn_hourly',
region: loc5,
scale: 30,
maxPixels: 1e13
});
// //2018
var dotCa8 = daymet47.map(p_day);
var dotCa8 = dotCa8.select(['inf_range','nic_range']);//select('over_T.*');
var dotCa8 = dotCa8.map(getStats);
var dotCa8 = dotCa8.toBands();
print('884 dotc', dotCa);
Export.image.toDrive({ image: dotCa8.toInt32(),
description: 'camden18_tmax_daycounts',
folder: 'daymet_txn_hourly',
region: loc1,