Skip to content

Commit

Permalink
fixes #1302
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Oct 5, 2023
1 parent 2d53740 commit 200ea85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/read_gdal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2081,8 +2081,10 @@ void SpatRasterSource::set_names_time_ncdf(std::vector<std::string> metadata, st

if (nms[2][2].empty()) {
unit = {""};
hasUnit = false;
} else {
unit = {nms[2][2]};
hasUnit = true;
}

recycle(unit, nlyr);
Expand Down
5 changes: 5 additions & 0 deletions src/spatRaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ SpatRaster SpatRaster::geometry(long nlyrs, bool properties, bool time, bool uni
long nl = nlyr();
bool keepnlyr = ((nlyrs == nl) || (nlyrs < 1));
nlyrs = (keepnlyr) ? nlyr(): nlyrs;

if (properties) {
s.hasColors = hasColors();
s.cols = getColors();
Expand All @@ -281,6 +282,10 @@ SpatRaster SpatRaster::geometry(long nlyrs, bool properties, bool time, bool uni
s.hasUnit = true;
s.unit = getUnit();
}
if (nsrc() == 1) {
s.source_name = source[0].source_name;
s.source_name_long = source[0].source_name_long;
}
} else {
for (size_t i=0; i < s.nlyr; i++) {
nms.push_back("lyr" + std::to_string(i+1));
Expand Down

0 comments on commit 200ea85

Please sign in to comment.