Skip to content

Commit

Permalink
Close and reopen memfile dataset before WarpedVRT (#165)
Browse files Browse the repository at this point in the history
Much safer and a future version of rasterio will require that datasets passed to WarpedVRT be opened in read-only mode.
  • Loading branch information
sgillies authored Sep 28, 2020
1 parent 66722af commit 83b0f68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contextily/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,14 @@ def _warper(img, transform, s_crs, t_crs, resampling):
crs=s_crs,
transform=transform,
) as mraster:
for band in range(b):
mraster.write(img[band, :, :], band + 1)
# --- Virtual Warp
mraster.write(img)

with memfile.open() as mraster:
with WarpedVRT(mraster, crs=t_crs, resampling=resampling) as vrt:
img = vrt.read()
bounds = vrt.bounds
transform = vrt.transform

return img, bounds, transform


Expand Down

0 comments on commit 83b0f68

Please sign in to comment.