@@ -30,8 +30,14 @@ function dimvals(a::RasterDataset, i)
3030 end
3131end
3232iscontdim (a:: RasterDataset , i) = i < 3 ? true : nraster (a)< 8
33- getattributes (a:: RasterDataset ) =
34- Dict {String,Any} (" projection" => ArchGDAL. toPROJ4 (ArchGDAL. newspatialref (ArchGDAL. getproj (a))))
33+ function getattributes (a:: RasterDataset )
34+ globatts = Dict {String,Any} (" projection" => ArchGDAL. toPROJ4 (ArchGDAL. newspatialref (ArchGDAL. getproj (a))))
35+ bands = (getbandattributes (ArchGDAL. getband (a, i)) for i in 1 : size (a, 3 ))
36+ allbands = mergewith (bands... ) do a1,a2
37+ isequal (a1,a2) ? a1 : missing
38+ end
39+ merge (globatts, allbands)
40+ end
3541
3642
3743function dimname (:: AbstractRasterBand , i)
@@ -54,5 +60,26 @@ function dimvals(b::AbstractRasterBand, i)
5460 end
5561end
5662iscontdim (a:: AbstractRasterBand , i) = true
57- getattributes (a:: AbstractRasterBand ) =
58- getattributes (ArchGDAL. RasterDataset (ArchGDAL. getdataset (a)))
63+ function getattributes (a:: AbstractRasterBand )
64+ atts = getattributes (ArchGDAL. RasterDataset (ArchGDAL. getdataset (a)))
65+ bandatts = getbandattributes (a)
66+ merge (atts, bandatts)
67+ end
68+
69+ function getbandattributes (a:: AbstractRasterBand )
70+ atts = Dict {String,Any} ()
71+ offs = ArchGDAL. getoffset (a)
72+ sf = ArchGDAL. getscale (a)
73+ missval = ArchGDAL. getnodatavalue (a)
74+ if ! iszero (offs)
75+ atts[" add_offset" ] = offs
76+ end
77+ if sf != one (sf)
78+ atts[" scale_factor" ] = sf
79+ end
80+ T = eltype (a)
81+ if missval != = nothing
82+ atts[" missing_value" ] = missval
83+ end
84+ atts
85+ end
0 commit comments