Skip to content

Commit

Permalink
Make RasterDataset not override custom cmaps (#422)
Browse files Browse the repository at this point in the history
* Make RasterDataset not override custom cmaps

Fixes #421

* Move if check outside of try for speed
  • Loading branch information
calebrob6 authored and adamjstewart committed Mar 19, 2022
1 parent bf848c1 commit 70578db
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,11 @@ def __init__(
try:
with rasterio.open(filepath) as src:
# See if file has a color map
try:
self.cmap = src.colormap(1)
except ValueError:
pass
if len(self.cmap) == 0:
try:
self.cmap = src.colormap(1)
except ValueError:
pass

if crs is None:
crs = src.crs
Expand Down

0 comments on commit 70578db

Please sign in to comment.