Skip to content

Commit

Permalink
Fix empty geometries
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstewart committed Aug 6, 2024
1 parent f07607a commit 9641f42
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions torchgeo/datasets/spacenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,19 @@ def _load_mask(
if feature['geometry']
]

mask_data = rasterize(
labels,
out_shape=shape,
fill=0, # nodata value
transform=tfm,
all_touched=False,
dtype=np.int64,
)
if labels:
mask = rasterize(
labels,
out_shape=shape,
fill=0, # nodata value
transform=tfm,
all_touched=False,
dtype=np.int64,
)
else:
mask = np.zeros(shape=shape)

return torch.from_numpy(mask_data)
return torch.from_numpy(mask)

def __getitem__(self, index: int) -> dict[str, Tensor]:
"""Return an index within the dataset.
Expand Down

0 comments on commit 9641f42

Please sign in to comment.