Skip to content

Commit

Permalink
Ensure that dataset exists when reading tags (#628)
Browse files Browse the repository at this point in the history
Previously this statement was outside the `ctx` context, and so `dataset` may already have been freed before we call `dataset.tags()`. In my experience, this was sporadically leading to either of the following errors:

```
rasterio.errors.RasterioIOError: Dataset is closed`
```

or 

```
rasterio._err.ObjectNullError: Pointer 'hObject' is NULL in 'GDALGetMetadata'.
```
  • Loading branch information
JackDunnNZ authored Jul 18, 2023
1 parent 584ecdb commit 0d862e7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rio_tiler/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ def point(
post_process=post_process,
)

return PointData(
img.array[:, 0, 0],
coordinates=coordinates,
crs=coord_crs,
band_names=img.band_names,
metadata=dataset.tags(),
)
return PointData(
img.array[:, 0, 0],
coordinates=coordinates,
crs=coord_crs,
band_names=img.band_names,
metadata=dataset.tags(),
)

0 comments on commit 0d862e7

Please sign in to comment.