Reputation: 305
I am trying to re-projected a .tiff file to EPSG:32638 with the following code.
Versions I have installed: Rasterio version 1.1.5 Numpy version 1.18.1
This is the code I am using:https://rasterio.readthedocs.io/en/latest/topics/reproject.html (Reprojecting a GeoTIFF dataset)
Error:
---------------------------------------------------------------------------
CPLE_BaseError Traceback (most recent call last)
rasterio/_crs.pyx in rasterio._crs._CRS.from_user_input()
rasterio/_err.pyx in rasterio._err.exc_wrap_ogrerr()
CPLE_BaseError: OGR Error code 6
During handling of the above exception, another exception occurred:
CRSError Traceback (most recent call last)
<ipython-input-35-aa94757a1fc2> in <module>
7 with rasterio.open('/home/DATA/Test.tif') as src:
8 transform, width, height = calculate_default_transform(
----> 9 src.crs, dst_crs, src.width, src.height, *src.bounds)
10 kwargs = src.meta.copy()
11 kwargs.update({
~/anaconda3/envs/elsa/lib/python3.7/site-packages/rasterio/env.py in wrapper(*args, **kwds)
380 def wrapper(*args, **kwds):
381 if local._env:
--> 382 return f(*args, **kwds)
383 else:
384 with Env.from_defaults():
~/anaconda3/envs/elsa/lib/python3.7/site-packages/rasterio/warp.py in calculate_default_transform(src_crs, dst_crs, width, height, left, bottom, right, top, gcps, resolution, dst_width, dst_height)
468
469 dst_affine, dst_width, dst_height = _calculate_default_transform(
--> 470 src_crs, dst_crs, width, height, left, bottom, right, top, gcps
471 )
472
rasterio/_warp.pyx in rasterio._warp._calculate_default_transform()
rasterio/_base.pyx in rasterio._base._osr_from_crs()
~/anaconda3/envs/elsa/lib/python3.7/site-packages/rasterio/crs.py in from_user_input(cls, value, morph_from_esri_dialect)
457 elif isinstance(value, string_types):
458 obj = cls()
--> 459 obj._crs = _CRS.from_user_input(value, morph_from_esri_dialect=morph_from_esri_dialect)
460 return obj
461 else:
rasterio/_crs.pyx in rasterio._crs._CRS.from_user_input()
CRSError: The WKT could not be parsed. OGR Error code 6
Upvotes: 17
Views: 6998
Reputation: 11
try upgrading rasterio
pip install rasterio --upgrade
then use the following code to test
from rasterio import open as rio_open
from rasterio.warp import calculate_default_transform, reproject, Resampling
src_path = '/home/DATA/Test.tif'
dst_path = '/home/DATA/Test_reprojected.tif'
dst_crs = 'EPSG:32638'
with rio_open(src_path) as src:
transform, width, height = calculate_default_transform(
src.crs, dst_crs, src.width, src.height, *src.bounds
)
kwargs = src.meta.copy()
kwargs.update({
'crs': dst_crs,
'transform': transform,
'width': width,
'height': height
})
with rio_open(dst_path, 'w', **kwargs) as dst:
for i in range(1, src.count + 1):
reproject(
source=rasterio.band(src, i),
destination=rasterio.band(dst, i),
src_transform=src.transform,
src_crs=src.crs,
dst_transform=transform,
dst_crs=dst_crs,
resampling=Resampling.nearest
)
print(f"Reprojected file saved to {dst_path}")
Upvotes: 0