I try to reproject the crs of a raster to another common coordinate system, using this code:

crs = QgsCoordinateReferenceSystem()
crs_1 = crs.createFromProj4("+proj=tmerc +lat_0=0 +lon_0=38.03333333333 +k=1 +x_0=2400000 +y_0=-6511057.63 +ellps=krass +towgs84=23.57,-140.95,-79.8,0,0.35,0.79,-0.22 +units=m +no_defs")
crs_2 = crs.createFromProj4("+proj=utm +zone=37 +datum=WGS84 +units=m +no_defs")

But it gives me following error:

Traceback (most recent call last):
  File "[...]\Python37\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
TypeError: QgsCoordinateTransform(): arguments did not match any overloaded call:
  overload 1: too many arguments
  overload 2: argument 1 has unexpected type 'bool'
  overload 3: argument 1 has unexpected type 'bool'
  overload 4: argument 1 has unexpected type 'bool'
  overload 5: argument 1 has unexpected type 'bool'

What am I doing wrong? Using EPSG numbers works but is for me no option.

(Win 10, QGIS 3.1)


createFromProj4 seems to return a boolean value which would explain the error. Try replacing this with fromProj4:

crs = QgsCoordinateReferenceSystem()
crs_1 = crs.fromProj4("+proj=tmerc +lat_0=0 +lon_0=38.03333333333 +k=1 +x_0=2400000 +y_0=-6511057.63 +ellps=krass +towgs84=23.57,-140.95,-79.8,0,0.35,0.79,-0.22 +units=m +no_defs")
crs_2 = crs.fromProj4("+proj=utm +zone=37 +datum=WGS84 +units=m +no_defs")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.