corteva / rioxarray

geospatial xarray extension powered by rasterio
https://corteva.github.io/rioxarray
Other
522 stars 84 forks source link

Reading Sentinel-5P data throws "UnicodeDecodeError" #527

Closed rrsc1234 closed 2 years ago

rrsc1234 commented 2 years ago

Hi. I am trying to read sentinel-5p data using following code:

import rioxarray
netcdf_fname = r'D:\Projects\S5P_OFFL_L2__CH4____20220509T074431_20220509T092601_23678_02_020301_20220510T234447.nc'
rds = rioxarray.open_rasterio(netcdf_fname, group='PRODUCT')

After running the above code I am getting following error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 28: invalid start byte

My installed rioxarray version is '0.9.1'.

Can someone please tell me how to reslove this issue.

Data is present at the following link: https://drive.google.com/file/d/1zw8kSPZPRIu_YDxixIlOByPCY19GNMbz/view?usp=sharing

snowman2 commented 2 years ago

Please provide the output of rioxarray.show_versions().

rrsc1234 commented 2 years ago

Please provide the output of rioxarray.show_versions().

Here is the output after running rioxarray.show_versions()

rioxarray (0.9.1) deps:
  rasterio: 1.0.18
    xarray: 0.20.1
      GDAL: 2.3.3

Other python deps:
     scipy: 1.1.0
    pyproj: 2.6.1.post1

System:
    python: 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)]
executable: C:\Users\user\Anaconda3\pythonw.exe
   machine: Windows-10-10.0.18362-SP0
None
snowman2 commented 2 years ago

I recommend upgrading.

When opening the file this is the output I see:

[<xarray.Dataset>
 Dimensions:      (y: 1, x: 4173, band: 1)
 Coordinates:
   * y            (y) float64 0.5
   * x            (x) float64 0.5 1.5 2.5 3.5 ... 4.17e+03 4.172e+03 4.172e+03
   * band         (band) int64 1
     spatial_ref  int64 0
 Data variables:
     delta_time   (band, y, x) int32 ...
     time_utc     (band, y, x) float32 ...
 Attributes: (12/53)
     algorithm_version:                  1.4.0
     build_date:                         2021-10-08T11:04:00Z
     cdm_data_type:                      Swath
     Conventions:                        CF-1.7
     cpp_compiler_flags:                 -g -O2 -fPIC -std=c++11 -W -Wall -Wno...
     cpp_compiler_version:               g++ (GCC) 4.8.5 20150623 (Red Hat 4.8...
     ...                                 ...
     time_reference:                     2022-05-06T00:00:00Z
     time_reference_days_since_1950:     26423
     time_reference_julian_day:          2459705.5
     time_reference_seconds_since_1970:  1651795200
     title:                              TROPOMI/S5P Methane 1-Orbit L2 Swath ...
     tracking_id:                        f51af69f-4113-4834-8ea0-6e675c261177,
 <xarray.Dataset>
 Dimensions:                              (y: 4173, x: 215, time: 1)
 Coordinates:
   * y                                    (y) float64 0.5 1.5 ... 4.172e+03
   * x                                    (x) float64 0.5 1.5 2.5 ... 213.5 214.5
   * time                                 (time) int64 389491200
     spatial_ref                          int64 0
 Data variables:
     qa_value                             (time, y, x) uint8 ...
     latitude                             (time, y, x) float32 ...
     longitude                            (time, y, x) float32 ...
     methane_mixing_ratio                 (time, y, x) float32 ...
     methane_mixing_ratio_precision       (time, y, x) float32 ...
     methane_mixing_ratio_bias_corrected  (time, y, x) float32 ...
 Attributes: (12/53)
     algorithm_version:                  1.4.0
     build_date:                         2021-10-08T11:04:00Z
     cdm_data_type:                      Swath
     Conventions:                        CF-1.7
     cpp_compiler_flags:                 -g -O2 -fPIC -std=c++11 -W -Wall -Wno...
     cpp_compiler_version:               g++ (GCC) 4.8.5 20150623 (Red Hat 4.8...
     ...                                 ...
     time_reference:                     2022-05-06T00:00:00Z
     time_reference_days_since_1950:     26423
     time_reference_julian_day:          2459705.5
     time_reference_seconds_since_1970:  1651795200
     title:                              TROPOMI/S5P Methane 1-Orbit L2 Swath ...
     tracking_id:                        f51af69f-4113-4834-8ea0-6e675c261177]

Version information:

rioxarray (0.11.1) deps:
  rasterio: 1.2.10
    xarray: 2022.3.0
      GDAL: 3.4.2
      GEOS: None
      PROJ: None
 PROJ DATA: None
 GDAL DATA: None

Other python deps:
     scipy: 1.8.0
    pyproj: 3.3.1

System:
    python: 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:38:57) [GCC 10.3.0]
executable: ~/miniconda/envs/midas/bin/python
   machine: Linux-5.13.0-41-generic-x86_64-with-glibc2.31
snowman2 commented 2 years ago

Side note: Python 3.7 is no longer supported. See #451.

rrsc1234 commented 2 years ago

Side note: Python 3.7 is no longer supported. See #451.

Thanks @snowman2. I changed python version and the issue got resolved.