I try to open a jp2 image with the Python's Rasterio package. The code is below. The problem is that the coordinate reference system is not recognised and when I want to see the meta attribute of the opened band I see that the crs is None.
import rasterio
b6_path = 'D:\\IKI\\1np\\myimage_band06.jp2'
b6 = rasterio.open(b6_path, driver='JP2OpenJPEG')
b6.meta
#output:
# {'driver': 'JP2OpenJPEG',
# 'dtype': 'uint16',
# 'nodata': None,
# 'width': 5490,
# 'height': 5490,
# 'count': 1,
# 'crs': None,
# 'transform': Affine(20.0, 0.0, 699960.0,
# 0.0, -20.0, 4900020.0)}
As I know what the coordinate system is, I tried to set it manually like this:
import rasterio.crs
crs = rasterio.crs.CRS({"init": "epsg:32634"})
b6.crs = crs
But when I call the CRS() function I get this error message:
CRSError: The EPSG code is unknown. Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.
I checked the GDAL_DATA variable by this command in the Anaconda prompt:
echo %GDAL_DATA%
the path to which the variable points to is: C:\Users\me\Miniconda3\Library\share\gdal
This folder contain a file named gcs.csv where the coordinate systems info should be so I do not know what is the problem? I found this discussion:
https://github.com/mapbox/rasterio/issues/1539
but it is too complicated for a beginner like me. Also, there seems to be no solution clearly stated there.
I am using Windows 10, Python 3.7, Miniconda 3, rasterio 1.0.28, and gdal 2.4.2
CRS.from_epsg(32634)
instead.