Skip to content

Commit c6f4a24

Browse files
authored
make sure to check if there is a file name before adding it (#430)
1 parent 79353bc commit c6f4a24

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/sources/gdal.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,20 +237,28 @@ function DD.metadata(raster::AG.RasterDataset, args...)
237237
scale = AG.getscale(band)
238238
offset = AG.getoffset(band)
239239
# norvw = AG.noverview(band)
240-
path = first(AG.filelist(raster))
241240
units = AG.getunittype(band)
242-
upair = units == "" ? () : ("units"=>units,)
243-
_metadatadict(GDALsource, "filepath"=>path, "scale"=>scale, "offset"=>offset, upair...)
241+
filelist = AG.filelist(raster)
242+
metadata = _metadatadict(GDALsource, "scale"=>scale, "offset"=>offset)
243+
if units == ""
244+
metadata["units"] = units
245+
end
246+
if length(filelist) > 0
247+
metadata["filepath"] = first(filelist)
248+
end
249+
return metadata
244250
end
245251

246252
# Rasters methods for ArchGDAL types ##############################
247253

248254
# Create a Raster from a dataset
249255
Raster(ds::AG.Dataset; kw...) = Raster(AG.RasterDataset(ds); kw...)
250256
function Raster(ds::AG.RasterDataset;
251-
crs=crs(ds), mappedcrs=nothing,
257+
crs=crs(ds),
258+
mappedcrs=nothing,
252259
dims=dims(ds, crs, mappedcrs),
253-
refdims=(), name=Symbol(""),
260+
refdims=(),
261+
name=Symbol(""),
254262
metadata=metadata(ds),
255263
missingval=missingval(ds)
256264
)

0 commit comments

Comments
 (0)