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

Loading netCDF from remote source fails #829

Open
StijnCaerts opened this issue Nov 12, 2024 · 1 comment
Open

Loading netCDF from remote source fails #829

StijnCaerts opened this issue Nov 12, 2024 · 1 comment
Labels
bug Something isn't working upstream Issue is related to a dependency (upstream package).

Comments

@StijnCaerts
Copy link

Code Sample, a copy-pastable example if possible

import rioxarray

local_file = "/tmp/c_gls_NDVI_202004010000_GLOBE_PROBAV_V3.0.1.nc"
with rioxarray.open_rasterio(local_file) as src:
    print(src.data_vars)

remote_file = "https://globalland.vito.be/download/netcdf/ndvi/ndvi_1km_v3_10daily/2020/20200401/c_gls_NDVI_202004010000_GLOBE_PROBAV_V3.0.1.nc"
with rioxarray.open_rasterio(remote_file) as src:
    print(src.data_vars)

Problem description

Loading netCDF files containing a time dimension fails when the file is located on a 'remote' source. For remote sources, like HTTP but also NFS shares, the NETCDF_DIM_time_VALUES tag is not set. This raises the following exception:

Traceback (most recent call last):
  File "/home/stijn/PycharmProjects/scratch/rioxarray_bug.py", line 8, in <module>
    with rioxarray.open_rasterio(remote_file) as src:
  File "/home/stijn/PycharmProjects/scratch/.venv/lib/python3.10/site-packages/rioxarray/_io.py", line 1147, in open_rasterio
    subdataset_result = _load_subdatasets(
  File "/home/stijn/PycharmProjects/scratch/.venv/lib/python3.10/site-packages/rioxarray/_io.py", line 829, in _load_subdatasets
    rioda: DataArray = open_rasterio(  # type: ignore
  File "/home/stijn/PycharmProjects/scratch/.venv/lib/python3.10/site-packages/rioxarray/_io.py", line 1192, in open_rasterio
    coords = _load_netcdf_1d_coords(attrs)
  File "/home/stijn/PycharmProjects/scratch/.venv/lib/python3.10/site-packages/rioxarray/_io.py", line 609, in _load_netcdf_1d_coords
    dim_values = _parse_netcdf_attr_array(tags[f"NETCDF_DIM_{dim_name}_VALUES"])
KeyError: 'NETCDF_DIM_time_VALUES'

Related topics in GDAL repository:

Expected Output

Data variables:
    NDVI       (time, y, x) uint8 632MB ...
    NDVI_unc   (time, y, x) int16 1GB ...
    NOBS       (time, y, x) uint8 632MB ...
    QFLAG      (time, y, x) uint8 632MB ...
    TIME_GRID  (time, y, x) int16 1GB ...

Environment Information

rioxarray (0.18.1) deps:
  rasterio: 1.3.10
    xarray: 2024.10.0
      GDAL: 3.8.4
      GEOS: 3.11.1
      PROJ: 9.3.1
 PROJ DATA: /home/stijn/PycharmProjects/scratch/.venv/lib/python3.10/site-packages/rasterio/proj_data
 GDAL DATA: /home/stijn/PycharmProjects/scratch/.venv/lib/python3.10/site-packages/rasterio/gdal_data

Other python deps:
     scipy: 1.14.1
    pyproj: 3.6.1

System:
    python: 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0]
executable: /home/stijn/PycharmProjects/scratch/.venv/bin/python
   machine: Linux-6.9.3-76060903-generic-x86_64-with-glibc2.35

Installation method

  • PyPi
@StijnCaerts StijnCaerts added the bug Something isn't working label Nov 12, 2024
@lagamura
Copy link

Hi @StijnCaerts, this was an issue in GDAL that has been resolved in recent versions >= 3.10
OSGeo/gdal#11207

@snowman2 snowman2 added the upstream Issue is related to a dependency (upstream package). label Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Issue is related to a dependency (upstream package).
Projects
None yet
Development

No branches or pull requests

3 participants