Пример #1
0
def pystac_workaround(uri):
    if uri.startswith('/vsizip/') and not uri.startswith('/vsizip//'):
        uri = uri.replace('/vsizip/', '/vsizip//')
    if uri.startswith(
            '/vsitar/vsigzip/') and not uri.startswith('/vsitar/vsigzip//'):
        uri = uri.replace('/vsitar/vsigzip/', '/vsitar/vsigzip//')

    return uri
    return VsiFileSystem.read_str(uri)
def noop_write_method(uri, txt):
    pass


def pystac_workaround(uri):
    if uri.startswith('/vsizip/') and not uri.startswith('/vsizip//'):
        uri = uri.replace('/vsizip/', '/vsizip//')
    if uri.startswith(
            '/vsitar/vsigzip/') and not uri.startswith('/vsitar/vsigzip//'):
        uri = uri.replace('/vsitar/vsigzip/', '/vsitar/vsigzip//')

    return uri

STAC_IO.read_text_method = \
    lambda uri: VsiFileSystem.read_str(pystac_workaround(uri))
STAC_IO.write_text_method = noop_write_method


def image_sources(item: Item, channel_order: [int]):
    image_keys = [key for key in item.assets.keys() if key.startswith("image")]
    image_keys.sort()
    image_uris = [
        VsiFileSystem.uri_to_vsi_path(item.assets[key].href)
        for key in image_keys
    ]
    return RasterioSourceConfig(
        uris=image_uris,
        channel_order=channel_order,
        transformers=[
            NanTransformerConfig(),
Пример #3
0
 def read_text(self, source, *args, **kwargs) -> str:
     return VsiFileSystem.read_str(pystac_workaround(source))