import xarray as xr
import rioxarray as rxr
import fsspec
import rasterio
fs = fsspec.filesystem('s3', requester_pays=True)
flist = fs.ls('pangeo-data-uswest2/esip/cogs')
flist
['pangeo-data-uswest2/esip/cogs/2016_PostMattew_CLNS_1mDEM_COG.tif', 'pangeo-data-uswest2/esip/cogs/2016_PostMattew_CLNS_1m_Intensity_COG.tif', 'pangeo-data-uswest2/esip/cogs/LO08_L1TP_067017_20130722_20190828_02_T1_B8.TIF', 'pangeo-data-uswest2/esip/cogs/back_river1_dem_cog.tif', 'pangeo-data-uswest2/esip/cogs/back_river1_ortho_cog.tif', 'pangeo-data-uswest2/esip/cogs/nlcd_2016_landcover_l48_edition_20190424_cog.tif', 'pangeo-data-uswest2/esip/cogs/srtm15_v2_cog.tif']
with fs.open(flist[4]) as f:
with rasterio.open(f) as dataset:
from rasterio.plot import show
print(dataset.shape)
show(dataset.read())
(11789, 7968)
with fs.open(flist[4]) as f:
da = rxr.open_rasterio(f)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /tmp/ipykernel_867/3335827488.py in <module> 1 with fs.open(flist[4]) as f: ----> 2 da = rxr.open_rasterio(f) /home/conda/store/acb2f024c6e8193fde99cded4bc262f3ebaa0295b7bda375655032f00b7a681f-default/lib/python3.9/site-packages/rioxarray/_io.py in open_rasterio(filename, parse_coordinates, chunks, cache, lock, masked, mask_and_scale, variable, group, default_name, decode_times, decode_timedelta, **open_kwargs) 842 843 # open the subdatasets if they exist --> 844 if riods.subdatasets: 845 return _load_subdatasets( 846 riods=riods, AttributeError: '_GeneratorContextManager' object has no attribute 'subdatasets'
with fs.open(flist[5]) as f:
da = rxr.open_rasterio(f)
print(da.crs)
crs = ccrs.AlbersEqualArea(central_longitude=-96, central_latitude=23, standard_parallels=(29.5,45.5))
%opts Image [colorbar=True] (cmap='magma')
da[0, 50000:51000, 80000:81000].hvplot(crs=crs)