I wish to subset my xarray Dataset
via a list of variable names. However, when I do so, the resultant Dataset no longer has the coordinate reference information, as evidenced by adding the subset as a layer in QGIS.
How can I keep the coordinate reference information after subsetting the original Dataset
?
import xarray as xr
DS = xr.open_dataset("my_data.nc")
bands = ['CMI_C01','CMI_C02','CMI_C03']
# Test does not have coordinate reference information :(
test = DS[bands]
It is apparent that the coordinate reference information is not stored in the .coords
attribute, due to the following not working:
# Test still does not have coordinate reference info
test = test.assign_coords(dict(DS.coords))
# When put into QGIS, does not have the CRS
test.to_netcdf("test.nc")
Where is the CRS stored for xarray Datasets?
For background, I am using GOES imagery from the public AWS s3 bucket.
This is what the original Dataset looks like:
Dimensions: (y: 1500, x: 2500,
number_of_time_bounds: 2,
number_of_image_bounds: 2, band: 1)
Coordinates: (3/37)
* t datetime64[ns] 2017-03-04T08:38:0...
* y (y) float32 0.1265 ... 0.04259
* x (x) float32 -0.07501 ... 0.06493.47
Attributes: (2/29)
naming_authority: gov.nesdis.noaa
Conventions: CF-1.7