@@ -460,12 +460,15 @@ def load_data(
460
460
return satellite_ds , dss_s2 , dss_ls
461
461
462
462
463
- def load_topobathy (
463
+ def load_topobathy_mask (
464
464
dc ,
465
- satellite_ds ,
465
+ geobox ,
466
466
product = "ga_ausbathytopo250m_2023" ,
467
+ elevation_band = "height_depth" ,
467
468
resampling = "bilinear" ,
468
469
mask_invalid = True ,
470
+ min_threshold = - 15 ,
471
+ mask_filters = [("dilation" , 25 )],
469
472
):
470
473
"""
471
474
Loads a topo-bathymetric DEM for the extents of the loaded satellite
@@ -476,38 +479,58 @@ def load_topobathy(
476
479
----------
477
480
dc : Datacube
478
481
A Datacube instance for loading data.
479
- satellite_ds : ndarray
480
- The loaded satellite data, used to obtain the spatial extents
481
- of the data .
482
+ geobox : ndarray
483
+ The GeoBox of the loaded satellite data, used to ensure the data
484
+ is loaded into the same pixel grid (e.g. resolution, extents, CRS) .
482
485
product : str, optional
483
486
The name of the topo-bathymetric DEM product to load from the
484
487
datacube. Defaults to "ga_ausbathytopo250m_2023".
488
+ elevation_band : str, optional
489
+ The name of the band containing elevation data. Defaults to
490
+ "height_depth".
485
491
resampling : str, optional
486
492
The resampling method to use, by default "bilinear".
487
493
mask_invalid : bool, optional
488
494
Whether to mask invalid/nodata values in the array by setting
489
495
them to NaN, by default True.
496
+ min_threshold : int or float, optional
497
+ The elevation value used to create the mask; all pixels with
498
+ elevations above this value will be given a value of True.
499
+ mask_filters : list of tuples, optional
500
+ An optional list of morphological processing steps to pass to
501
+ the `mask_cleanup` function. The default is `[("dilation", 25)]`,
502
+ which will dilate True pixels by a radius of 25 pixels (~250 m).
490
503
491
504
Returns
492
505
-------
493
- topobathy_ds : xarray.Dataset
494
- The loaded topo-bathymetric DEM.
506
+ topobathy_ds : xarray.DataArray
507
+ An output boolean mask, where True represent pixels to use in the
508
+ following analysis.
495
509
"""
496
- topobathy_ds = dc .load (
497
- product = product , like = satellite_ds .odc .geobox .compat , resampling = resampling
498
- ).squeeze ("time" )
510
+ # Load from datacube, reprojecting to GeoBox of input satellite data
511
+ topobathy_ds = dc .load (product = product , like = geobox , resampling = resampling ).squeeze (
512
+ "time"
513
+ )
499
514
500
515
# Mask invalid data
501
516
if mask_invalid :
502
517
topobathy_ds = mask_invalid_data (topobathy_ds )
503
518
504
- return topobathy_ds
519
+ # Threshold to minumum elevation
520
+ topobathy_mask = topobathy_ds [elevation_band ] > min_threshold
521
+
522
+ # If requested, apply cleanup
523
+ if mask_filters is not None :
524
+ topobathy_mask = mask_cleanup (topobathy_mask , mask_filters = mask_filters )
525
+
526
+ return topobathy_mask
505
527
506
528
507
- def load_aclum (
529
+ def load_aclum_mask (
508
530
dc ,
509
- satellite_ds ,
531
+ geobox ,
510
532
product = "abares_clum_2020" ,
533
+ class_band = "alum_class" ,
511
534
resampling = "nearest" ,
512
535
mask_invalid = True ,
513
536
):
@@ -521,12 +544,15 @@ def load_aclum(
521
544
----------
522
545
dc : Datacube
523
546
A Datacube instance for loading data.
524
- satellite_ds : ndarray
525
- The loaded satellite data, used to obtain the spatial extents
526
- of the data .
547
+ geobox : ndarray
548
+ The GeoBox of the loaded satellite data, used to ensure the data
549
+ is loaded into the same pixel grid (e.g. resolution, extents, CRS) .
527
550
product : str, optional
528
551
The name of the ABARES land use dataset product to load from the
529
552
datacube. Defaults to "abares_clum_2020".
553
+ class_band : str, optional
554
+ The name of the band containing land use class data. Defaults to
555
+ "alum_class".
530
556
resampling : str, optional
531
557
The resampling method to use, by default "nearest".
532
558
mask_invalid : bool, optional
@@ -535,22 +561,23 @@ def load_aclum(
535
561
536
562
Returns
537
563
-------
538
- reclassified_aclum : xarray.Dataset
539
- The ABARES land use mask, summarised to include only two land
540
- use classes: 'intensive urban' and ' other' .
564
+ reclassified_aclum : xarray.DataArray
565
+ An output boolean mask, where True equals intensive urban and
566
+ False equals all other classes .
541
567
"""
568
+ # Load from datacube, reprojecting to GeoBox of input satellite data
542
569
aclum_ds = dc .load (
543
- product = product , like = satellite_ds . odc . geobox . compat , resampling = resampling
570
+ product = product , like = geobox , resampling = resampling
544
571
).squeeze ("time" )
545
572
546
573
# Mask invalid data
547
574
if mask_invalid :
548
575
aclum_ds = mask_invalid_data (aclum_ds )
549
576
550
577
# Manually isolate the 'intensive urban' land use summary class, set
551
- # all other pixels to false . For class definitions, refer to
578
+ # all other pixels to False . For class definitions, refer to
552
579
# gdata1/data/land_use/ABARES_CLUM/geotiff_clum_50m1220m/Land use, 18-class summary.qml)
553
- reclassified_aclum = aclum_ds . alum_class .isin (
580
+ reclassified_aclum = aclum_ds [ class_band ] .isin (
554
581
[
555
582
500 ,
556
583
530 ,
@@ -926,7 +953,7 @@ def export_dataset_metadata(
926
953
Dataset maturity to use for the output dataset. Default is
927
954
"final", can also be "interim".
928
955
additional_metadata : dict, optional
929
- An option dictionary containing additional metadata fields to
956
+ An option dictionary containing additional metadata fields to
930
957
add to the dataset metadata properties.
931
958
debug : bool, optional
932
959
When true, this will write S3 outputs locally so they can be
0 commit comments