new tile loader
This commit is contained in:
parent
1566ea788d
commit
2f35f831a4
36
minigrida/loader/coord_tiles.py
Normal file
36
minigrida/loader/coord_tiles.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# file coord_tiles.py
|
||||||
|
# author Florent Guiotte <florent.guiotte@irisa.fr>
|
||||||
|
# version 0.0
|
||||||
|
# date 29 mai 2020
|
||||||
|
"""Abstract
|
||||||
|
|
||||||
|
doc.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
import rasterio as rio
|
||||||
|
import logging
|
||||||
|
|
||||||
|
log = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
|
def run(rasters_path, rasters_name, gt_suffix='gt.tif'):
|
||||||
|
gt_names = list(Path(rasters_path).glob('*' + gt_suffix))
|
||||||
|
log.info('Found {} ground truth tiles.'.format(len(gt_names)))
|
||||||
|
|
||||||
|
gt = []
|
||||||
|
rasters = []
|
||||||
|
|
||||||
|
for gtn in gt_names:
|
||||||
|
print(gtn)
|
||||||
|
gt += [load_tif(gtn)]
|
||||||
|
|
||||||
|
rasters += [{Path(n).stem: load_tif(gtn.as_posix().strip(gt_suffix) + n)
|
||||||
|
for n in rasters_name}]
|
||||||
|
|
||||||
|
return gt, rasters
|
||||||
|
|
||||||
|
|
||||||
|
def load_tif(path):
|
||||||
|
return rio.open(str(path)).read()[0]
|
||||||
Loading…
Reference in New Issue
Block a user