issues: 376389539
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
376389539 | MDU6SXNzdWUzNzYzODk1Mzk= | 2535 | HDF error when trying to write Dataset read with rasterio to NetCDF | 5638829 | closed | 0 | 17 | 2018-11-01T13:21:15Z | 2023-03-29T16:01:26Z | 2023-03-29T16:01:26Z | NONE | I'm getting an HDF error when trying to write a Dataset read from GeoTiff (rasterio backend) to NetCDF. See reproducible example below: ```python import urllib.request import tempfile import os import xarray as xr path = tempfile.gettempdir() url = 'https://earthexplorer.usgs.gov/browse/gisready/landsat_8/LC08_L1TP_026047_20180110_20180119_01_T1.zip' filename = os.path.join(path, url.split('/')[-1]) nc_name = os.path.join(path, 'landsat_rgb.nc') Download file if not exist (11 Mb)if not os.path.isfile(filename): urllib.request.urlretrieve(url, filename) Read rgb file using rasterio backendrgb_name = '/'.join(['/vsizip', filename, os.path.basename(filename).split('.')[-2] + '.tif']) ds = xr.open_rasterio(rgb_name) ds = ds.to_dataset('band').rename({1:'blue', 2:'green', 3:'red'}) print(ds) <xarray.Dataset>Dimensions: (x: 7611, y: 7761)Coordinates:* y (y) float64 2.193e+06 2.193e+06 2.193e+06 ... 1.961e+06 1.960e+06* x (x) float64 3.732e+05 3.732e+05 3.733e+05 ... 6.015e+05 6.015e+05Data variables:blue (y, x) uint8 ...red (y, x) uint8 ...green (y, x) uint8 ...Attributes:transform: (30.0, 0.0, 373185.0, 0.0, -30.0, 2193315.0)crs: +init=epsg:32614res: (30.0, 30.0)is_tiled: 1nodatavals: (nan, nan, nan)Write to netcdfds.to_netcdf(nc_name) ``` Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2535/reactions", "total_count": 2, "+1": 2, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |