new tile loader

This commit is contained in:
Florent Guiotte 2020-05-29 10:03:45 +02:00
parent 1566ea788d
commit 2f35f831a4

View 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]