I'm working on a simple script using GDAL Driver.CreateCopy function, but I keep getting the same error. The script is very basic:
import os,arcpy,sys from osgeo import gdal source_folder=r'E:\to_conv' conv_folder='E:\conv' compression_type='JPEG' compression_quality='70' arcpy.env.workspace=source_folder rasters=arcpy.ListRasters("*","TIF") for raster in rasters: tiff_file=os.path.join(conv_folder,raster) source_file=os.path.join(source_folder,raster) print(source_file) try: dformat="GTiff" driver = gdal.GetDriverByName( dformat ) metadata = driver.GetMetadata() if metadata.has_key(gdal.DCAP_CREATE) and metadata[gdal.DCAP_CREATE] == 'YES': print 'Driver %s supports Create() method.' % dformat if metadata.has_key(gdal.DCAP_CREATECOPY) and metadata[gdal.DCAP_CREATECOPY] == 'YES': print 'Driver %s supports CreateCopy() method.' % dformat src_ds = gdal.Open(source_file) dst_ds = driver.CreateCopy(tiff_file,source_file, options=["ALPHA=YES"] ) except Exception: e=sys.exc_info()[1] print ("Error converting "+ source_file + " to " + tiff_file + ": " +str(e)) This is the error that I keep getting:
E:\to_conv\testfile1.tif Driver GTiff supports Create() method. Driver GTiff supports CreateCopy() method. Error converting E:\to_conv\testfile1.tif to E:\conv\testfile1.tif: in method 'Driver_CreateCopy', argument 3 of type 'GDALDatasetShadow *' Any help ?
dst_ds = driver.CreateCopy(tiff_file,source_file, 0)?gdaltest.tiff_drv.CreateCopy('/vsimem/rgb_added_alpha.tif', ds, options=['ALPHA=YES']).