Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/hdf4 subdatasets #410

Merged
merged 3 commits into from
Aug 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions podpac/core/data/rasterio_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from collections import OrderedDict
import io
import re

from six import string_types
import traitlets as tl
Expand Down Expand Up @@ -48,12 +49,13 @@ class Rasterio(LoadFileMixin, BaseFileSource):

@cached_property
def dataset(self):
try:
return super(Rasterio, self).dataset
except OSError: # This can happen if the dataset has subdatasets
if re.match(".*:.*:.*", self.source):
# i.e. user supplied a non-file-looking string like 'HDF4_EOS:EOS_GRID:"MOD13Q1.A2013033.h08v05.006.2015256072248.hdf":MODIS_Grid_16DAY_250m_500m_VI:"250m 16 days NDVI"'
jmilloy marked this conversation as resolved.
Show resolved Hide resolved
# This also includes many subdatsets as part of GDAL data drivers; https://gdal.org/drivers/raster/index.html
self.set_trait("read_from_source", True)
return rasterio.open(self.source)
else:
return super(Rasterio, self).dataset

@tl.default("band")
def _band_default(self):
Expand Down