Skip to content

Commit

Permalink
handle Nones in get_label
Browse files Browse the repository at this point in the history
  • Loading branch information
burakekim authored Jan 3, 2025
1 parent 5d94e18 commit 068c731
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torchgeo/datasets/eurocrops.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def get_label(self, feature: 'fiona.model.Feature') -> int:
# We go up the class hierarchy until there is a match.
# (Parent code is computed by replacing rightmost non-0 character with 0.)
hcat_code = feature['properties'][self.label_name]
if hcat_code is None:
print(f"Feature does not contain the label '{self.label_name}'. Skip rendering.")
return 0

while True:
if hcat_code in self.class_map:
return self.class_map[hcat_code]
Expand Down

0 comments on commit 068c731

Please sign in to comment.