2

When I try gdal warp in Jupyter lab I get the error below. Also, I add the full error below.

TypeError: in method 'wrapper_GDALWarpDestName', argument 4 of type 'GDALWarpAppOptions *'

gdal.Warp(output_path, input, format = 'GTiff', dstSRS = 'EPSG:4326 ')

I am working in Ubuntu(not anaconda env) and also in the Docker file. As you see, the code is very simple. In Docker, also I try in Python console in cmd and I got the same error.

I open this issue because first, I supposed that the reasons could be my Docker env but I got the same error in my local env. I have been using the same code for basic translation jobs and I haven't changed anything in my python env.

Any idea?

gdal version= 2.4.0

Full error

    TypeError                                 Traceback (most recent call last)
<ipython-input-20-7fb1940e5e91> in <module>
----> 1 gdal.Warp(r'./data/elevation_tif/EarthEnv-DEM90_N40W005.tif', './data/elevation_files/EarthEnv-DEM90_N40W005/EarthEnv-DEM90_N40W005.bil', format = 'GTiff', dstSRS = 'EPSG:4326 ')

~/Documents/geo/lib/python3.6/site-packages/osgeo/gdal.py in Warp(destNameOrDestDS, srcDSOrSrcDSTab, **kwargs)
    599 
    600     if _is_str_or_unicode(destNameOrDestDS):
--> 601         return wrapper_GDALWarpDestName(destNameOrDestDS, srcDSTab, opts, callback, callback_data)
    602     else:
    603         return wrapper_GDALWarpDestDS(destNameOrDestDS, srcDSTab, opts, callback, callback_data)

~/Documents/geo/lib/python3.6/site-packages/osgeo/gdal.py in wrapper_GDALWarpDestName(*args)
   3351 def wrapper_GDALWarpDestName(*args):
   3352     """wrapper_GDALWarpDestName(char const * dest, int object_list_count, GDALWarpAppOptions warpAppOptions, GDALProgressFunc callback=0, void * callback_data=None) -> Dataset"""
-> 3353     return _gdal.wrapper_GDALWarpDestName(*args)
   3354 class GDALVectorTranslateOptions(_object):
   3355     """Proxy of C++ GDALVectorTranslateOptions class."""

TypeError: in method 'wrapper_GDALWarpDestName', argument 4 of type 'GDALWarpAppOptions *'
1
  • You have to remove the space at the end of the dstSRS string, so ‘EPSG:4326’ and not ‘EPSG:4326 ‘. Jan 13 at 12:29

3 Answers 3

1

You may have to replace dstSRS='EPSG:4326' with gdal.WarpOptions(dstSRS='EPSG:4326') to get rid of the error that you are getting. You are supplying a keyword object where a gdal.WarpOptions object is needed.

0

I think the error is in the order of the arguments. try this way

    import gdal 
    input = r"D:\ESCUELA\ hh.bil"
    out =  "D:\ESCUELA\ prueba.tif"

     gdal.Warp(srcDSOrSrcDSTab = input,
          destNameOrDestDS=out,
          format = "GTiff",
          dstSRS= 'EPSG:3795')

You try this way

      gdal.Translate(srcDS = input,
          destName=out,
          format = "GTiff")

if they don't work for you I recommend you check the syntax of the addresses or the status of your input file. I hope to be helpful

3
  • Thanks for the reply. I get same error
    – Iroh
    May 3, 2020 at 19:53
  • Take a look at the new trial edition with gdal.Translate. Both are run in my program ,if not working tell me, for help you find another way I hope it is helpful May 3, 2020 at 21:39
  • I solve my problem by upgrading my Gdal version. When I upgrade Gdal, I got an error and I put the solution of my error. Also, I tried to create clean venv in my local machine. When I install Gdal 'pip install GDAL' I got an error same as below link. I am not sure, maybe my local Python has a problem. If I find something, I will update my question. [github.com/OSGeo/gdal/issues/880#issuecomment-571353272]
    – Iroh
    May 4, 2020 at 11:35
0

I was having the same error, using WarpOptions and everything. The order of the arguments was right as well. For me, what fixed it was making sure the SRS was being provided strictly as a string with the format 'EPSG:numericepsgcodehere'.

I suspect that your problem might be on your string, because you have a space character in the end of it. Instead of gdal.Warp(output_path, input, format = 'GTiff', dstSRS = 'EPSG:4326 ') I will suggest you try

gdal.Warp(output_path, input, format = 'GTiff', dstSRS = 'EPSG:4326')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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