예제 #1
0
def test_open_rasterio_http():
    prefix = 'https://landsat-pds.s3.us-west-2.amazonaws.com/L8/139/045'
    image = 'LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF'
    url = f'{prefix}/{image}'
    source = intake.open_rasterio(url, chunks=dict(band=1))
    ds = source.to_dask()
    assert isinstance(ds, xr.core.dataarray.DataArray)
예제 #2
0
def test_http_open_rasterio_auth(data_server):
    url = f'{data_server}/RGB.byte.tif'
    auth = dict(client_kwargs={'auth': aiohttp.BasicAuth('USER', 'PASS')})
    # NOTE: if url startswith 'https' use 'https' instead of 'http' for storage_options
    source = intake.open_rasterio(url, storage_options=dict(http=auth))
    source_auth = source.storage_options['http'].get('client_kwargs').get(
        'auth')
    assert isinstance(source_auth, aiohttp.BasicAuth)
예제 #3
0
def test_http_read_rasterio(data_server):
    url = f'{data_server}/RGB.byte.tif'
    source = intake.open_rasterio(url)
    da = source.read()
    assert da.attrs['crs'] == '+init=epsg:32618'
    assert da.attrs['AREA_OR_POINT'] == 'Area'
    assert da.dtype == 'uint8'
    assert da.isel(band=2, x=300, y=500).values == 129
예제 #4
0
def test_http_read_rasterio(data_server):
    url = f'{data_server}/RGB.byte.tif'
    source = intake.open_rasterio(url)
    da = source.read()
    # Following line: original file CRS appears to be updated
    assert "+init" in da.attrs['crs'] or "+proj" in da.attrs['crs']
    assert da.attrs['AREA_OR_POINT'] == 'Area'
    assert da.dtype == 'uint8'
    assert da.isel(band=2, x=300, y=500).values == 129
예제 #5
0
def test_open_rasterio_s3():
    bucket = 's3://landsat-pds'
    key = 'L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF'
    url = f'{bucket}/{key}'
    source = intake.open_rasterio(url,
                                  chunks=dict(band=1),
                                  storage_options=dict(anon=True))
    ds = source.to_dask()
    assert isinstance(ds, xr.core.dataarray.DataArray)
예제 #6
0
 def getDataSource(self, **kwargs) -> DataSource:
     try:
         datasource = intake.open_rasterio(self.files[0], chunks={})
         datasource.discover()
         return datasource
     except Exception as err:
         print(
             f"Error opening Aviris file (skipping): {self.files[0]}: {err}"
         )
         return None
예제 #7
0
def test_http_read_rasterio_pattern(data_server):
    url = [
        data_server + '/' + x for x in ('little_red.tif', 'little_green.tif')
    ]
    source = intake.open_rasterio(url,
                                  path_as_pattern='{}/little_{color}.tif',
                                  concat_dim='color',
                                  chunks={})
    da = source.to_dask()
    assert isinstance(da, xr.core.dataarray.DataArray)
    assert set(da.color.data) == set(['red', 'green'])
    assert da.shape == (2, 3, 64, 64)
예제 #8
0
def test_s3_read_rasterio(s3):
    # Lots of GDAL Environment variables needed for this to work !
    # https://gdal.org/user/virtual_file_systems.html#vsis3-aws-s3-files
    os.environ['AWS_NO_SIGN_REQUEST'] = 'YES'
    os.environ['AWS_S3_ENDPOINT'] = endpoint_uri.lstrip('http://')
    os.environ['AWS_VIRTUAL_HOSTING'] = 'FALSE'
    os.environ['AWS_HTTPS'] = 'NO'
    os.environ['GDAL_DISABLE_READDIR_ON_OPEN'] = 'EMPTY_DIR'
    os.environ['CPL_CURL_VERBOSE'] = 'YES'
    url = f's3://{test_bucket_name}/RGB.byte.tif'
    source = intake.open_rasterio(url)
    da = source.read()
    assert da.attrs['crs'] == '+init=epsg:32618'
    assert da.attrs['AREA_OR_POINT'] == 'Area'
    assert da.dtype == 'uint8'
    assert da.isel(band=2, x=300, y=500).values == 129
예제 #9
0
def test_http_read_rasterio_simplecache(data_server):
    url = f'simplecache::{data_server}/RGB.byte.tif'
    source = intake.open_rasterio(url, chunks={})
    da = source.to_dask()
    assert isinstance(da, xr.core.dataarray.DataArray)
예제 #10
0
def test_http_open_rasterio_dask(data_server):
    url = f'{data_server}/RGB.byte.tif'
    source = intake.open_rasterio(url, chunks={})
    da = source.to_dask()
    assert isinstance(da, xr.core.dataarray.DataArray)
    assert isinstance(da.data, dask.array.core.Array)