Skip to content

Instantly share code, notes, and snippets.

@AndrewAnnex
Created July 31, 2020 23:51
Show Gist options
  • Save AndrewAnnex/b5da9cb02014238763830a04557cf2f6 to your computer and use it in GitHub Desktop.
Save AndrewAnnex/b5da9cb02014238763830a04557cf2f6 to your computer and use it in GitHub Desktop.
rasterio read speed test helper function
import rasterio as rio
import concurrent.futures as cf
def fc(p,n=4):
with rio.open(p) as src:
blocks = [_[1] for _ in src.block_windows()]
def rf(w):
with rio.open(p) as src:
data=src.read(window=w)
return data
with cf.ThreadPoolExecutor(max_workers=n) as ex:
x = list(ex.map(rf, blocks))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment