Skip to content

Commit

Permalink
add comments for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
isaaccorley committed Sep 6, 2022
1 parent 4481114 commit 2ed7a7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions torchgeo/datasets/idtrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,15 @@ def _load_boxes(self, path: str) -> Tensor:
geometries = cast(Dict[int, Dict[str, Any]], self.geometries)

# Find object ids and geometries
# The train set geometry->image mapping is contained
# in the train/Field/itc_rsFile.csv file
if self.split == "train":
indices = self.labels["rsFile"] == base_path
ids = self.labels[indices]["id"].tolist()
geoms = [geometries[i]["geometry"]["coordinates"][0][:4] for i in ids]
# Test set - Task 2 has no mapping csv. Mapping is inside of geometry
# The test set has no mapping csv. The mapping is inside of the geometry
# properties i.e. geom["property"]["plotID"] contains the RGB image filename
# Return all geometries with the matching RGB image filename of the sample
else:
ids = [
k
Expand Down Expand Up @@ -397,9 +401,10 @@ def _load_geometries(self, directory: str) -> Dict[int, Dict[str, Any]]:
for path in filepaths:
with fiona.open(path) as src:
for feature in src:
# The train set has a unique id for each geometry in the properties
if self.split == "train":
features[feature["properties"]["id"]] = feature
# Test set task 2 has no id
# The test set has no unique id so create a dummy id
else:
id = len(features) + 1
features[id] = feature
Expand Down

0 comments on commit 2ed7a7f

Please sign in to comment.