/
wms_cfg_example.py
1990 lines (1966 loc) · 96.2 KB
/
wms_cfg_example.py
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
import re
# Static config for the wms metadata.
# pylint: skip-file
response_cfg = {
"Access-Control-Allow-Origin": "*", # CORS header
}
service_cfg = {
## Which web service(s) should be supported by this instance
# Defaults: wms: True, wcs: False, wmts: False
# Notes:
# WMTS support is implemented as a thin proxy to WMS. Some corners of the spec are interpreted
# somewhat loosely. In particular exception documents are directly translated from the underlying
# WMS error and are unlikely to be fully compliant with the WMTS standard.
"wcs": True,
"wms": True,
"wmts": True,
## Required config for WMS and/or WCS
# Service title - appears e.g. in Terria catalog
"title": "WMS server for Australian Landsat Datacube",
# Service URL. Should a fully qualified URL or a list of fully qualified URLs that the service can return
# in the GetCapabilities document based on the requesting url
"url": [ "http://9xjfk12.nexus.csiro.au/datacube_wms", "http://alternateurl.nexus.csiro.au/datacube_wms" ],
# URL that humans can visit to learn more about the WMS or organization
# should be fully qualified
"human_url": "http://csiro.au",
# Provide S3 data URL for data_links in GetFeatureinfo
"s3_url": "http://data.au",
# Provide S3 bucket name for data_links in GetFeatureinfo
"s3_bucket": "s3_bucket_name",
# Supported co-ordinate reference systems
"published_CRSs": {
"EPSG:3857": { # Web Mercator
"geographic": False,
"horizontal_coord": "x",
"vertical_coord": "y",
},
"EPSG:4326": { # WGS-84
"geographic": True,
"vertical_coord_first": True
},
"EPSG:3577": { # GDA-94, internal representation
"geographic": False,
"horizontal_coord": "x",
"vertical_coord": "y",
},
},
## Required config for WCS
# Must be a geographic CRS in the published_CRSs list. EPSG:4326 is recommended, but any geographic CRS should work.
"default_geographic_CRS": "EPSG:4326",
# Supported WCS formats
"wcs_formats": {
# Key is the format name, as used in DescribeCoverage XML
"GeoTIFF": {
# Renderer is the FQN of a Python function that takes:
# * A WCSRequest object
# * Some ODC data to be rendered.
"renderer": "datacube_wms.wcs_utils.get_tiff",
# The MIME type of the image, as used in the Http Response.
"mime": "image/geotiff",
# The file extension to add to the filename.
"extension": "tif",
# Whether or not the file format supports multiple time slices.
"multi-time": False
},
"netCDF": {
"renderer": "datacube_wms.wcs_utils.get_netcdf",
"mime": "application/x-netcdf",
"extension": "nc",
"multi-time": True,
}
},
# The native wcs format must be declared in wcs_formats above.
"native_wcs_format": "GeoTIFF",
## Optional config for instances supporting WMS
# Max tile height/width. If not specified, default to 256x256
"max_width": 512,
"max_height": 512,
# Optional config for all services (WMS and/or WCS) - may be set to blank/empty, no defaults
"abstract": """Historic Landsat imagery for Australia.""",
"keywords": [
"landsat",
"australia",
"time-series",
],
"contact_info": {
"person": "David Gavin",
"organisation": "Geoscience Australia",
"position": "Technical Lead",
"address": {
"type": "postal",
"address": "GPO Box 378",
"city": "Canberra",
"state": "ACT",
"postcode": "2906",
"country": "Australia",
},
"telephone": "+61 2 1234 5678",
"fax": "+61 2 1234 6789",
"email": "test@example.com",
},
"fees": "",
"access_constraints": "",
# If True this will not calculate spatial extents
# in update_ranges.py but will instead use a default
# extent covering much of Australia for all
# temporal extents
# False by default (calculate spatial extents)
"use_default_extent": True,
# If using GeoTIFFs as storage
# this will set the rasterio env
# GDAL Config for GTiff Georeferencing
# See https://www.gdal.org/frmt_gtiff.html#georeferencing
"geotiff_georeference_source": "INTERNAL",
# Attribution. This entire section is optional. If provided, it is taken as the
# default attribution for any layer that does not override it.
"attribution": {
# Attribution must contain at least one of ("title", "url" and "logo")
# A human readable title for the attribution - e.g. the name of the attributed organisation
"title": "Digital Earth Australia",
# The associated - e.g. URL for the attributed organisation
"url": "http://www.ga.gov.au/dea",
# Logo image - e.g. for the attributed organisation
"logo": {
# Image width in pixels (optional)
"width": 370,
# Image height in pixels (optional)
"height": 73,
# URL for the logo image. (required if logo specified)
"url": "https://www.ga.gov.au/__data/assets/image/0011/61589/GA-DEA-Logo-Inline-370x73.png",
# Image MIME type for the logo - should match type referenced in the logo url (required if logo specified.)
"format": "image/png",
}
},
# These define the AuthorityURLs. They represent the authorities that define the layer "Identifiers" below.
# The spec allows AuthorityURLs to be defined anywhere on the Layer heirarchy, but datacube_ows treats them
# as global entities.
"authorities": {
# The authorities dictionary maps names to authority urls.
"dea": "https://www.ga.gov.au",
"idrus": "https://www.identifiers-r-us.com",
}
}
layer_cfg = [
# Layer Config is a list of platform configs
{
# Name and title of the platform layer.
# Platform layers are not mappable. The name is for internal server use only.
"name": "LANDSAT_8",
"title": "Landsat 8",
"abstract": "Images from the Landsat 8 satellite",
# Attribution. This entire section is optional. If provided, it overrides any
# attribution defined in the service_cfg for all layers under this
# platform that do not define their own attribution.
"attribution": {
# Attribution must contain at least one of ("title", "url" and "logo")
# A human readable title for the attribution - e.g. the name of the attributed organisation
"title": "Digital Earth Australia",
# The associated - e.g. URL for the attributed organisation
"url": "http://www.ga.gov.au/dea",
# Logo image - e.g. for the attributed organisation
"logo": {
# Image width in pixels (optional)
"width": 370,
# Image height in pixels (optional)
"height": 73,
# URL for the logo image. (required if logo specified)
"url": "https://www.ga.gov.au/__data/assets/image/0011/61589/GA-DEA-Logo-Inline-370x73.png",
# Image MIME type for the logo - should match type referenced in the logo url (required if logo specified.)
"format": "image/png",
}
},
# Products available for this platform.
# For each product, the "name" is the Datacube name, and the label is used
# to describe the label to end-users.
"products": [
{
# Included as a keyword for the layer
"label": "NBAR-T",
# Included as a keyword for the layer
"type": "surface reflectance",
# Included as a keyword for the layer
"variant": "terrain corrected",
# The WMS name for the layer
"name": "ls8_nbart_albers",
# The Datacube name for the associated data product
"product_name": "ls8_nbart_albers",
# The Datacube name for the associated pixel-quality product (optional)
# The name of the associated Datacube pixel-quality product
"pq_dataset": "ls8_pq_albers",
# The name of the measurement band for the pixel-quality product
# (Only required if pq_dataset is set)
"pq_band": "pixelquality",
# Supported bands, mapping native band names to a list of possible aliases.
# 1. Aliases must be unique for the product.
# 2. Band aliases can be used anywhere in the configuration that refers to bands by name.
# 3. The native band name MAY be explicitly declared as an alias for the band, but are always treated as
# a valid alias.
# 4. The band labels used in GetFeatureInfo and WCS responses will be the first declared alias (or the native name
# if no aliases are declared.)
# 5. Bands NOT listed here will not be included in the GetFeatureInfo output and cannot be referenced
# elsewhere in the configuration.
# 6. If not specified for a product, defaults to all available bands, using only their native names.
"bands": {
"red": ["crimson"],
"green": [],
"blue": [ "azure" ],
"nir": [ "near_infrared" ],
"swir1": [ "shortwave_infrared_1", "near_shortwave_infrared" ],
"swir2": [ "shortwave_infrared_2", "far_shortwave_infrared" ],
"coastal_aerosol": [ "far_blue" ],
},
# Min zoom factor - sets the zoom level where the cutover from indicative polygons
# to actual imagery occurs.
"min_zoom_factor": 500.0,
# Min zoom factor (above) works well for small-tiled requests, (e.g. 256x256 as sent by Terria).
# However, for large-tiled requests (e.g. as sent by QGIS), large and intensive queries can still
# go through to the datacube.
# max_datasets_wms specifies a maximum number of datasets that a GetMap request can retrieve.
# Indicatative polygons are displayed if a request exceeds the limits imposed by EITHER max_dataset_wms
# OR min_zoom_factor.
# max_datasets_wms should be set in conjunction with min_zoom_factor so that Terria style 256x256
# tiled requests respond consistently - you never want to see a mixture of photographic tiles and polygon
# tiles at a given zoom level. i.e. max_datasets_wms should be greater than the number of datasets
# required for most intensive possible photographic query given the min_zoom_factor.
# Note that the ideal value may vary from product to product depending on the size of the dataset
# extents for the product.
# Defaults to zero, which is interpreted as no dataset limit.
# 6 seems to work with a min_zoom_factor of 500.0 for "old-style" Net-CDF albers tiled data.
"max_datasets_wms": 6,
# max_datasets_wcs is the WCS equivalent of max_datasets_wms. The main requirement for setting this
# value is to avoid gateway timeouts on overly large WCS requests (and reduce server load).
"max_datasets_wcs": 16,
# The fill-colour of the indicative polygons when zoomed out.
# Triplets (rgb) or quadruplets (rgba) of integers 0-255.
"zoomed_out_fill_colour": [150, 180, 200, 160],
# Extent mask function
# Determines what portions of dataset is potentially meaningful data.
# Multiple extent mask functions are supported - see USGS Level 1 example below.
#
# Three formats are supported:
# 1. A function object or lambda
# e.g. "extent_mask_func": lambda data, band: (data[band] != data[band].attrs['nodata']),
#
# 2. A string containing a fully qualified path to a python function (e.g. as shown below)
#
# 3. A dict containing the following elements:
# a) "function" (required): A string containing the fully qualified path to a python function
# b) "args" (optional): An array of additional positional arguments that will always be passed to the function.
# c) "kwargs" (optional): An array of additional keyword arguments that will always be passed to the function.
# d) "pass_product_cfg" (optional): Boolean (defaults to False). If true, the relevant ProductLayerConfig is passed
# to the function as a keyword argument named "product_cfg". This is useful if you are passing band aliases
# to the function in the args or kwargs. The product_cfg allows the index function to convert band aliases to
# to band names.
#
# The function is assumed to take two arguments, data (an xarray Dataset) and band (a band name). (Plus any additional
# arguments required by the args and kwargs values in format 3, possibly including product_cfg.)
#
"extent_mask_func": "datacube_wms.ogc_utils.mask_by_val",
# Fuse func
# Determines how multiple dataset arrays are compressed into a single time array
# All the formats described above for "extent_mask_func" are supported here as well.
"fuse_func": "datacube_wms.wms_utils.wofls_fuser",
# PQ Fuse func
# Determines how multiple dataset arrays are compressed into a single time array for the PQ layer
# All the formats described above for "extent_mask_func" are supported here as well.
"pq_fuse_func": "datacube.helpers.ga_pq_fuser",
# PQ Ignore time
# Doesn't use the time from the data to find a corresponding mask layer
# Used when you have a mask layer that doesn't have time
"pq_ignore_time": True,
# Flags listed here are ignored in GetFeatureInfo requests.
# (defaults to empty list)
"ignore_info_flags": [],
# Include an additional list of utc dates in the WMS Get Feature Info
# HACK: only used for GSKY non-solar day lookup
"feature_info_include_utc_dates": True,
# Set to true if the band product dataset extents include nodata regions.
"data_manual_merge": False,
# Set to true if the pq product dataset extents include nodata regions.
"pq_manual_merge": False,
# Bands to always fetch from the Datacube, even if it is not used by the active style.
# Useful for when a particular band is always needed for the extent_mask_func,
"always_fetch_bands": [ ],
# Time resolution of the product. Controls the way ODC time query parameters are generated.
#
# Defaults to "raw". Supported values are:
#
# "raw": The default. For sub-day time resolution, e.g. raw (unsummarised) EO data.
# Also works fine for DEA packaged summary data where the "from" and "to" dates
# are both set to the start of the summary time period.
#
# "month":
# "year" : For data summarised to monthly or yearly resolution respectively.
# Needed for e.g. summary data with EO3-style metadata with the "from" and "to"
# dates set to the start and end of the summary time period.
"time_resolution": "raw",
# Apply corrections for solar angle, for "Level 1" products.
# (Defaults to false - should not be used for NBAR/NBAR-T or other Analysis Ready products
"apply_solar_corrections": False,
# If this value is set then WCS works exclusively with the configured
# date and advertises no time dimension in GetCapabilities.
# Intended mostly for WCS debugging.
"wcs_sole_time": "2017-01-01",
# The default bands for a WCS request.
# 1. Must be provided if WCS is activated.
# 2. Must contain at least one band.
# 3. All bands must exist
# 4. Bands may be referred to by either native name or alias
"wcs_default_bands": [ "red", "green", "azure" ],
# The "native" CRS for WCS.
# Can be omitted if the product has a single native CRS, as this will be used in preference.
"native_wcs_crs": "EPSG:3577",
# The resolution (x,y) for WCS.
# This is the number of CRS units (e.g. degrees, metres) per pixel in the horizontal and vertical
# directions for the native resolution. E.g. for a EPSG:3577 (25.0,25.0) for Landsat-8 and (10.0,10.0 for Sentinel-2)
"native_wcs_resolution": [ 25.0, 25.0 ],
# The Identifiers section declares authoritative identifiers for the layer, and is optional
"identifiers": {
# Each key of the identifiers dictionary must match a name from the authorities dictionary
# in the service config. The values are the identifiers defined for this layer by that
# authority.
"dea": "ls8_ard",
"idsrus": "1234245::0054450::GSH::34567-splunge"
},
# FeatureListURLs and DataURLs are optional.
# Multiple of each may be defined per product.
# FeatureListURLs point to "a list of the features represented in a Layer".
# DataURLs "offer a link to the underlying data represented by a particular layer"
"feature_list_urls": [
{
"url": "http://domain.tld/path/to/page.html",
"format": "text/html"
},
{
"url": "http://another-domain.tld/path/to/image.png",
"format": "image/png"
}
],
"data_urls": [
{
"url": "http://abc.xyz/data-link.xml",
"format": "application/xml"
}
],
# Styles.
#
# See band_mapper.py
#
# The various available spectral bands, and ways to combine them
# into a single rgb image.
# The examples here are ad hoc
#
# LS7: http://www.indexdatabase.de/db/s-single.php?id=8
# LS8: http://www.indexdatabase.de/db/s-single.php?id=168
"styles": [
# Examples of styles which are linear combinations of the available spectral bands.
#
{
"name": "simple_rgb",
"title": "Simple RGB",
"abstract": "Simple true-colour image, using the red, green and blue bands",
"components": {
# The component keys MUST be "red", "green" and "blue" (and optionally "alpha")
"red": {
# Band aliases may be used here.
"crimson": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"blue": 1.0
}
},
# The raw band value range to be compressed to an 8 bit range for the output image tiles.
# Band values outside this range are clipped to 0 or 255 as appropriate.
"scale_range": [0.0, 3000.0]
},
{
"name": "cloud_masked_rgb",
"title": "Simple RGB with cloud masking",
"abstract": "Simple true-colour image, using the red, green and blue bands, with cloud masking",
"components": {
"red": {
"red": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"blue": 1.0
}
},
# PQ masking example
# All pixels where any of the listed flags are true are masked out.
"pq_masks": [
{
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
},
},
],
"scale_range": [0.0, 3000.0]
},
{
"name": "cloud_and_shadow_masked_rgb",
"title": "Simple RGB with cloud and cloud shadow masking",
"abstract": "Simple true-colour image, using the red, green and blue bands, with cloud and cloud shadow masking",
"components": {
"red": {
"red": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"blue": 1.0
}
},
# PQ masking example
"pq_masks": [
{
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
"cloud_shadow_acca": "no_cloud_shadow",
"cloud_shadow_fmask": "no_cloud_shadow",
},
},
],
"scale_range": [0.0, 3000.0]
},
{
"name": "extended_rgb",
"title": "Extended RGB",
"abstract": "Extended true-colour image, incorporating the coastal aerosol band",
"components": {
"red": {
"red": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"blue": 0.6,
"coastal_aerosol": 0.4
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "wideband",
"title": "Wideband false-colour",
"abstract": "False-colour image, incorporating all available spectral bands",
"components": {
"red": {
"swir2": 0.255,
"swir1": 0.45,
"nir": 0.255,
},
"green": {
"nir": 0.255,
"red": 0.45,
"green": 0.255,
},
"blue": {
"green": 0.255,
"blue": 0.45,
"coastal_aerosol": 0.255,
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "infra_red",
"title": "False colour multi-band infra-red",
"abstract": "Simple false-colour image, using the near and short-wave infra-red bands",
"components": {
"red": {
"swir1": 1.0
},
"green": {
"swir2": 1.0
},
"blue": {
"nir": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "coastal_aerosol",
"title": "Spectral band 1 - Coastal aerosol",
"abstract": "Coastal aerosol band, approximately 435nm to 450nm",
"components": {
"red": {
"coastal_aerosol": 1.0
},
"green": {
"coastal_aerosol": 1.0
},
"blue": {
"coastal_aerosol": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "blue",
"title": "Spectral band 2 - Blue",
"abstract": "Blue band, approximately 453nm to 511nm",
"components": {
"red": {
"blue": 1.0
},
"green": {
"blue": 1.0
},
"blue": {
"blue": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "green",
"title": "Spectral band 3 - Green",
"abstract": "Green band, approximately 534nm to 588nm",
"components": {
"red": {
"green": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"green": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "red",
"title": "Spectral band 4 - Red",
"abstract": "Red band, roughly 637nm to 672nm",
"components": {
"red": {
"red": 1.0
},
"green": {
"red": 1.0
},
"blue": {
"red": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "nir",
"title": "Spectral band 5 - Near infra-red",
"abstract": "Near infra-red band, roughly 853nm to 876nm",
"components": {
"red": {
"nir": 1.0
},
"green": {
"nir": 1.0
},
"blue": {
"nir": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "swir1",
"title": "Spectral band 6 - Short wave infra-red 1",
"abstract": "Short wave infra-red band 1, roughly 1575nm to 1647nm",
"components": {
"red": {
"swir1": 1.0
},
"green": {
"swir1": 1.0
},
"blue": {
"swir1": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "swir2",
"title": "Spectral band 7 - Short wave infra-red 2",
"abstract": "Short wave infra-red band 2, roughly 2117nm to 2285nm",
"components": {
"red": {
"swir2": 1.0
},
"green": {
"swir2": 1.0
},
"blue": {
"swir2": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
#
# Examples of non-linear colour-ramped styles.
{
"name": "ndvi",
"title": "NDVI",
"abstract": "Normalised Difference Vegetation Index - a derived index that correlates well with the existence of vegetation",
# The index function is continuous value from which the heat map is derived.
#
# Three formats are supported:
# 1. A function object or lambda
# e.g. "index_function": lambda data: (data["nir"] - data["red"]) / (data["nir"] + data["red"]),
# Note that lambdas CANNOT use band aliases - they MUST use the native band name
#
# 2. A string containing a fully qualified path to a python function
# e.g. "index_function": "datacube_wms.ogc_utils.not_a_real_function_name",
#
# 3. A dict containing the following elements:
# a) "function" (required): A string containing the fully qualified path to a python function
# b) "args" (optional): An array of additional positional arguments that will always be passed to the function.
# c) "kwargs" (optional): An array of additional keyword arguments that will always be passed to the function.
# d) "pass_product_cfg" (optional): Boolean (defaults to False). If true, the relevant ProductLayerConfig is passed
# to the function as a keyword argument named "product_cfg". This is useful if you are passing band aliases
# to the function in the args or kwargs. The product_cfg allows the index function to convert band aliases to
# to band names.
#
# The function is assumed to take one arguments, an xarray Dataset. (Plus any additional
# arguments required by the args and kwargs values in format 3, possibly including product_cfg.)
#
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "nir",
"band2": "red"
}
},
# Band aliases can be used here.
"needed_bands": ["red", "nir"],
# The color ramp. Values between specified entries have both their alphas and colours
# interpolated.
"color_ramp": [
# Any value less than the first entry will have colour and alpha of the first entry.
# (i.e. in this example all negative values will be fully transparent (alpha=0.0).)
{
"value": -0.0,
"color": "#8F3F20",
"alpha": 0.0
},
{
"value": 0.0,
"color": "#8F3F20",
"alpha": 1.0
},
{
# do not have to defined alpha value
# if no alpha is specified, alpha will default to 1.0
# or max opacity
"value": 0.1,
"color": "#A35F18"
},
{
"value": 0.2,
"color": "#B88512"
},
{
"value": 0.3,
"color": "#CEAC0E"
},
{
"value": 0.4,
"color": "#E5D609"
},
{
"value": 0.5,
"color": "#FFFF0C"
},
{
"value": 0.6,
"color": "#C3DE09"
},
{
"value": 0.7,
"color": "#88B808"
},
{
"value": 0.8,
"color": "#529400"
},
{
"value": 0.9,
"color": "#237100"
},
# Values greater than the last entry will use the colour and alpha of the last entry.
# (N.B. This will not happen for this example because it is normalised so that 1.0 is
# maximum possible value.)
{
"value": 1.0,
"color": "#114D04"
}
],
"legend": {
# Instead of using the generated color ramp legend for the style, a URL to a PNG file can
# be used instead.
"url": "http://example.com/custom_style_image.png"
}
},
{
"name": "ndvi_cloudmask",
"title": "NDVI with cloud masking",
"abstract": "Normalised Difference Vegetation Index (with cloud masking) - a derived index that correlates well with the existence of vegetation",
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "nir",
"band2": "red"
}
},
"needed_bands": ["red", "nir"],
# If a "range" is supplied instead of a "color_ramp", a default color ramp is used.
# Areas where the index_function returns less the lower range limit are transparent.
# Areas where the index_function returns within the range limits are mapped to a
# simple heat map ranging from dark blue, through blue, green, yellow, orange, and red to dark red.
# Areas where the index_function returns greater than the upper range limit are displayed as dark red.
"range": [0.0, 1.0],
"pq_masks": [
{
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
},
},
],
},
{
"name": "ndwi",
"title": "NDWI",
"abstract": "Normalised Difference Water Index - a derived index that correlates well with the existence of water",
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "green",
"band2": "nir"
}
},
"needed_bands": ["green", "nir"],
"range": [0.0, 1.0],
},
{
"name": "ndwi_cloudmask",
"title": "NDWI with cloud and cloud-shadow masking",
"abstract": "Normalised Difference Water Index (with cloud and cloud-shadow masking) - a derived index that correlates well with the existence of water",
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "green",
"band2": "nir"
}
},
"needed_bands": ["green", "nir"],
"range": [0.0, 1.0],
"pq_masks": [
{
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
},
},
],
},
{
"name": "ndbi",
"title": "NDBI",
"abstract": "Normalised Difference Buildup Index - a derived index that correlates with the existence of urbanisation",
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "swir2",
"band2": "nir"
}
},
"needed_bands": ["swir2", "nir"],
"range": [0.0, 1.0],
},
# Mask layers - examples of how to display raw pixel quality data.
# This works by creatively mis-using the colormap styles.
# The index function returns a constant, so the output is a flat single colour, masked by the
# relevant pixel quality flags.
{
"name": "cloud_mask",
"title": "Cloud Mask",
"abstract": "Highlight pixels with cloud.",
"index_function": {
"function": "datacube_wms.band_utils.constant",
"pass_product_cfg": True,
"kwargs": {
"band": "red",
"const": "0.1"
}
},
"needed_bands": ["red"],
"range": [0.0, 1.0],
# Mask flags normally describe which areas SHOULD be shown.
# (i.e. pixels for which any of the declared flags are true)
# pq_mask_invert is intended to invert this logic.
# (i.e. pixels for which none of the declared flags are true)
#
# i.e. Specifying like this shows pixels which are not clouds in either metric.
# Specifying "cloud" and setting the "pq_mask_invert" to False would
# show pixels which are not clouds in both metrics.
"pq_masks": [
{
"invert": True,
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
},
},
],
},
{
"name": "cloud_and_shadow_mask",
"title": "Cloud and Shadow Mask",
"abstract": "Highlight pixels with cloud or cloud shadow.",
"index_function": {
"function": "datacube_wms.band_utils.constant",
"pass_product_cfg": True,
"kwargs": {
"band": "red",
"const": "0.6"
}
},
"needed_bands": ["red"],
"range": [0.0, 1.0],
"pq_masks": [
{
"invert": True,
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
"cloud_shadow_acca": "no_cloud_shadow",
"cloud_shadow_fmask": "no_cloud_shadow",
},
},
],
},
{
"name": "cloud_acca",
"title": "Cloud acca Mask",
"abstract": "Highlight pixels with cloud.",
"index_function": {
"function": "datacube_wms.band_utils.constant",
"pass_product_cfg": True,
"kwargs": {
"band": "red",
"const": "0.4"
}
},
"needed_bands": ["red"],
"range": [0.0, 1.0],
"pq_masks": [
{
"flags": {
"cloud_acca": "cloud",
},
},
],
},
{
"name": "cloud_fmask",
"title": "Cloud fmask Mask",
"abstract": "Highlight pixels with cloud.",
"index_function": {
"function": "datacube_wms.band_utils.constant",
"pass_product_cfg": True,
"kwargs": {
"band": "red",
"const": "0.8"
}
},
"needed_bands": ["red"],
"range": [0.0, 1.0],
"pq_masks": [
{
"flags": {
"cloud_fmask": "cloud",
},
},
],
},
{
"name": "contiguous_mask",
"title": "Contiguous Data Mask",
"abstract": "Highlight pixels with non-contiguous data",
"index_function": {
"function": "datacube_wms.band_utils.constant",
"pass_product_cfg": True,
"kwargs": {
"band": "red",
"const": "0.3"
}
},
"needed_bands": ["red"],
"range": [0.0, 1.0],
"pq_masks": [
{
"flags": {
"contiguous": False
},
},
],
},
# Hybrid style - blends a linear mapping and an colour-ramped index style
# There is no scientific justification for these styles, I just think they look cool. :)
{
"name": "rgb_ndvi",
"title": "NDVI plus RGB",
"abstract": "Normalised Difference Vegetation Index (blended with RGB) - a derived index that correlates well with the existence of vegetation",
# Mixing ration between linear components and colour ramped index. 1.0 is fully linear components, 0.0 is fully colour ramp.
"component_ratio": 0.6,
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "nir",
"band2": "red"
}
},
"needed_bands": ["red", "nir"],
"range": [0.0, 1.0],
"components": {
"red": {
"red": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"blue": 1.0
}
},
"scale_range": [0.0, 3000.0]
},
{
"name": "rgb_ndvi_cloudmask",
"title": "NDVI plus RGB (Cloud masked)",
"abstract": "Normalised Difference Vegetation Index (blended with RGB and cloud masked) - a derived index that correlates well with the existence of vegetation",
"component_ratio": 0.6,
"index_function": {
"function": "datacube_wms.band_utils.norm_diff",
"pass_product_cfg": True,
"kwargs": {
"band1": "nir",
"band2": "red"
}
},
"needed_bands": ["red", "nir"],
"range": [0.0, 1.0],
"components": {
"red": {
"red": 1.0
},
"green": {
"green": 1.0
},
"blue": {
"blue": 1.0
}
},
"pq_masks": [
{
"flags": {
"cloud_acca": "no_cloud",
"cloud_fmask": "no_cloud",
},