I want to export a data cube (hyperspectral data) to a .tif file using the rio.to_raster module, which should be inside the rioxarray package.
But when I try to recall the module (rio.to_raster) it seems that doesn’t exist, even if I installed and imported the rioxarray package.
So I imported all the libraries I need:
#Importing libraries
import rioxarray as riox
import numpy as np
Then, trying to do this:
M3_hull_export=M3_hull.copy()
M3_hull_export.data[M3_hull_export.data==0]=np.nan
M3_hull_export.rio.to_raster(f'{path_results}/{target}_conremoved_CH.tif') #Uncomment if you want to export the continuum-removed file
Obtaining this error:
CPLE_OpenFailedError Traceback (most recent call last)
File rasterio\_io.pyx:1488, in rasterio._io.DatasetWriterBase.__init__()
File rasterio\_err.pyx:221, in rasterio._err.exc_wrap_pointer()
CPLE_OpenFailedError: Attempt to create new tiff file '/D:/PhD_CISAS/M3_Marius_conremoved_CH.tif' failed: No error
During handling of the above exception, another exception occurred:
RasterioIOError Traceback (most recent call last)
Cell In[12], line 5
3 M3_hull_export=M3_hull.copy()
4 M3_hull_export.data[M3_hull_export.data==0]=np.nan
----> 5 M3_hull_export.rio.to_raster(f'{path_results}/{target}_conremoved_CH.tif')
File c:Usersmelchanaconda3Libsite-packagesrioxarrayraster_array.py:1133, in RasterArray.to_raster(self, raster_path, driver, dtype, tags, windowed, recalc_transform, lock, compute, **profile_kwargs)
1114 out_profile = {
1115 key: value
1116 for key, value in out_profile.items()
(...)
1127 )
1128 }
1129 rio_nodata = (
1130 self.encoded_nodata if self.encoded_nodata is not None else self.nodata
...
344 )
File rasterio\_io.pyx:1493, in rasterio._io.DatasetWriterBase.__init__()
RasterioIOError: Attempt to create new tiff file '/D:/PhD_CISAS/M3_Marius_conremoved_CH.tif' failed: No error
I try to write this line to know more details:
import sys
print(riox.rio.to_raster.__file__)
AttributeError Traceback (most recent call last)
Cell In[13], line 5
1 #import sys
2 #print(MoonIndex.preparation.__file__)
4 import sys
----> 5 print(riox.rio.to_raster.__file__)
AttributeError: module 'rioxarray' has no attribute 'rio'
I don’t know what to do to solve this problem, I thank in advance whoever will answer this question.
user26346265 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.