diff --git a/malpolon/data/datasets/torchgeo_datasets.py b/malpolon/data/datasets/torchgeo_datasets.py index efd8b6b..f7419cd 100644 --- a/malpolon/data/datasets/torchgeo_datasets.py +++ b/malpolon/data/datasets/torchgeo_datasets.py @@ -10,6 +10,8 @@ import numpy as np import pandas as pd +import rasterio +import geopandas as gpd import pyproj from pyproj import CRS, Transformer from torchgeo.datasets import BoundingBox, RasterDataset @@ -26,6 +28,17 @@ ALL_NORTHERN_EPSG_CODES = list(range(32601, 32662)) EUROPE_EPSG_CODE = [3035] +def intersects_with_img(roi, file_list): + res = False + for file in file_list: + with rasterio.open(file) as ds : + tf = ds.meta.copy()['transform'] + bounds = (tf[2], ds.width*tf[0]+tf[2], ds.height*tf[4]+tf[5], tf[5]) + if (roi.minx>bounds[0]) & (roi.miny>bounds[2]) & (roi.maxx