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

Use rasterio to read modis_lst #166

Open
jacobwhall opened this issue Feb 14, 2023 · 0 comments
Open

Use rasterio to read modis_lst #166

jacobwhall opened this issue Feb 14, 2023 · 0 comments

Comments

@jacobwhall
Copy link
Member

Installed from pip, rasterio doesn't support less-common data formats out of the box. This affects two datasets I've tested, ltdr_ndvi and modis_lst. I'm working on the ltdr_ndvi fix now, and leaving this issue so that we can revisit modis_lst.

  1. build rasterio with more expansive gdal file support (not from pip wheel). There are two ways I've tested to achieve this:
    1. conda install -c conda-forge rasterio
    2. pip install --force-reinstall --no-binary rasterio rasterio
  2. load modis_lst file using rasterio instead of pyhdf
    from pathlib import Path
    import rasterio
    
    file_path = Path("/dir/modis.hdf").as_posix()
    gdal_path = f"HDF4_EOS:EOS_GRID:\"{file_path}\":MODIS_MONTHLY_0.05DEG_CMG_LST:LST_Day_CMG"
    src = rasterio.open(gdal_path)
    # ...

The easiest way I could find to determine the correct gdal path to use to load an image

from osgeo import gdal
# load raster file
ds = gdal.Open("modis.hdf", gdal.GA_ReadOnly)
# print list of sub datasets in the file
print(ds.GetSubDatasets())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant