Search code examples
pythongdal

Why does gdal.translate not accept a third argument?


According to the docs, gdal.Translate should accept three arguments. The code snippet below is copied directly from the definition file gdal.py

 def Translate(destName, srcDS, **kwargs):

My function call looks like this :

 gdal.Translate(tileName, rasterfile, options)

My IDE ( VScode) instantly notices that something is off, and tells me that ther are too many arguemnts given. Running the code leads to the following error message:

Traceback (most recent call last): File "c:/Users/parejo/Desktop/tile_gen.py", line 24, in gdal.Translate(tileName, rasterfile, options) TypeError: Translate() takes 2 positional arguments but 3 were given

What am I missing here?

Code itself is fine, if i remove the options argument, everything runs smoothly, but as i am missing my options, i dont get the results i want.


Solution

  • Try to call with this (didnt tested code)

    gdal.Translate(tileName, rasterfile, *options)