My specifications :
- Python 3.9.1
- gdal 3.1.4
- rasterio 1.1.8
- Windows 10 Business
- conda version 4.9.2
I have a raster that has no crs :
os.chdir(path)
file_list= os.listdir()
file_list[0]
>>> RGEALTI_FXX_0605_6670_MNT_LAMB93_IGN69.asc
with rasterio.open(liste_fichiers[0]) as src:
print(src.profile)
print(src.crs)
print(src.bounds)
print(src.indexes)
>>> {'driver': 'AAIGrid', 'dtype': 'float32', 'nodata': -99999.0, 'width': 1000, 'height': 1000, 'count': 1, 'crs': None, 'transform': Affine(5.0, 0.0, 604997.5,
0.0, -5.0, 6670002.5), 'tiled': False}
None
BoundingBox(left=604997.5, bottom=6665002.5, right=609997.5, top=6670002.5)
(1,)
For your information, I do have a GDAL_DATA environment variable. (I found this information here).
When I open the raster with QGIS, I can in fact notice that there is no CRS, but on the other hand I can easily select one. I am looking forward to do the same with rasterio. Here is the code I tried to do so :
with rasterio.open(liste_fichiers[0], mode='r+') as src:
print(src.profile)
src.crs = rasterio.crs.CRS.from_epsg(2154)
>>> {'driver': 'AAIGrid', 'dtype': 'float32', 'nodata': -99999.0, 'width': 1000, 'height': 1000, 'count': 1, 'crs': None, 'transform': Affine(5.0, 0.0, 604997.5,
0.0, -5.0, 6670002.5), 'tiled': False}
CPLE_AppDefinedError Traceback (most recent call last)
<ipython-input-191-a0546e13d796> in <module>
1 with rasterio.open(liste_fichiers[0], mode='r+') as src:
2 print(src.profile)
----> 3 src.crs = rasterio.crs.CRS.from_epsg(2154)
rasterio_base.pyx in rasterio._base.DatasetBase.exit()
rasterio_base.pyx in rasterio._base.DatasetBase.close()
rasterio_io.pyx in rasterio._io.BufferedDatasetWriterBase.stop()
rasterio_io.pyx in rasterio._io._delete_dataset_if_exists()
rasterio_err.pyx in rasterio._err.exc_wrap_int()
CPLE_AppDefinedError: Deleting RGEALTI_FXX_0605_6670_MNT_LAMB93_IGN69.asc failed: Permission denied
5698code you mentionned and yet received the same error message. – Basile Jan 15 '21 at 15:26