diff --git a/telluric/features.py b/telluric/features.py index 7c3f2f54..d8c1de83 100644 --- a/telluric/features.py +++ b/telluric/features.py @@ -16,7 +16,7 @@ from telluric import GeoRaster2 -raster_types = [RASTER_TYPE] +raster_types = [RASTER_TYPE, "image/x.geotiff"] def transform_properties(properties, schema): @@ -305,11 +305,12 @@ def has_raster(self): """True if any of the assets is type 'raster'.""" return any(asset.get('type') == RASTER_TYPE for asset in self.assets.values()) - def raster(self, name=None, **creteria): + def raster(self, name=None, validate_raster_type=True, **creteria): """Generates a GeoRaster2 object based on the asset name(key) or a creteria(protety name and value).""" if name: asset = self.assets[name] - if asset["type"] in raster_types: + asset_type = asset.get("type") + if asset_type in raster_types or not validate_raster_type: __object = asset.get('__object') if isinstance(__object, GeoRaster2): return __object diff --git a/telluric/georaster.py b/telluric/georaster.py index 444e2445..5d9e244c 100644 --- a/telluric/georaster.py +++ b/telluric/georaster.py @@ -2049,8 +2049,11 @@ def from_assets(cls, assets): return None elif len(assets) > 1: return GeoMultiRaster.from_assets(assets) - raster = list(assets.values())[0] - return GeoRaster2.open(raster["href"], band_names=raster["bands"]) + if isinstance(assets, dict): + raster = list(assets.values())[0] + elif isinstance(assets, list): + raster = assets[0] + return GeoRaster2.open(raster.get("href"), band_names=raster.get("bands") or raster.get("eo:bands")) RasterChunk = namedtuple('RasterChunk', ["raster", "offsets"]) diff --git a/telluric/vrt.py b/telluric/vrt.py index dcc8550e..6734b364 100644 --- a/telluric/vrt.py +++ b/telluric/vrt.py @@ -246,9 +246,15 @@ def max_resolution(): xsize = raster.width * raster.affine.a / affine.a ysize = raster.height * raster.affine.e / affine.e dst_window = Window(xoff, yoff, xsize, ysize) - file_name = raster.source_file if relative_to_vrt else os.path.join(os.getcwd(), raster.source_file) + if relative_to_vrt: + file_name = raster.source_file + else: + if raster.source_file.startswith("http"): + file_name = "/vsicurl/%s" % raster.source_file + else: + file_name = raster.source_file if relative_to_vrt else os.path.join(os.getcwd(), raster.source_file) - vrt.add_band_simplesource(band_element, band_idx, raster.dtype, relative_to_vrt, file_name, + vrt.add_band_simplesource(band_element, i + 1, raster.dtype, relative_to_vrt, file_name, raster.width, raster.height, raster.block_shape(i)[1], raster.block_shape(i)[0], src_window, dst_window)