Skip to content

Commit

Permalink
Address PR comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
petewa authored and mergify[bot] committed Dec 11, 2019
1 parent 198530c commit bf0c9fd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions datacube/utils/xarray_geoextensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ def _get_crs(obj):
# Assumption: spatial dimensions are always the last 2)
spatial_dims = data_array.dims[-2:]
crs_set = set(data_array[d].attrs.get('crs', None) for d in spatial_dims)
crs = None
if len(crs_set) > 1:
raise ValueError('Spatial dimensions have different crs.')
elif len(crs_set) == 1 and None not in crs_set:
crs = data_array[data_array.dims[-1]].crs
else:
elif len(crs_set) == 1:
crs = crs_set.pop()

if crs is None:
# fall back option
crs = data_array.attrs.get('crs', None) or obj.attrs.get('crs', None)
return crs
Expand Down

0 comments on commit bf0c9fd

Please sign in to comment.