nanders

Conflict arcpy (Arc 10) and gdal?

Discussion created by nanders on Jun 1, 2011
Latest reply on Jul 21, 2011 by kjnether
Dear all,

Since a year or so, I happily combine the arctools with gdal and python functionality.
However, since I upgraded to ArcGIS 10 I ran into a number of problems.

My biggest issue is this:

The following code works fine:
import arcpy

arcpy.CheckOutExtension("Spatial")
raster = 'E:/temp/raster.img'
shapefile = 'E:/temp/shapefile.shp'

mask = arcpy.sa.ExtractByMask(raster,shapefile)
mask.save('E:/temp/test.img')


However, when I add 'from osgeo import gdal' at the very beginning, I get an error message that some conversion from arcobjects to python object couldn't finish:
from osgeo import gdal
import arcpy

arcpy.CheckOutExtension("Spatial")
raster = 'E:/temp/raster.img'
shapefile = 'E:/temp/shapefile.shp'

mask = arcpy.sa.ExtractByMask(raster,shapefile)
mask.save('E:/temp/test.img')

>>> 
Traceback (most recent call last):
  File "E:\temp\ivan\testing3.py", line 8, in <module>
    mask = arcpy.sa.ExtractByMask(raster,shapefile)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 6726, in ExtractByMask
    in_mask_data)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Utils.py", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\sa\Functions.py", line 6722, in wrapper
    out_raster)
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\geoprocessing\_base.py", line 474, in <lambda>
    return lambda *args: val(*gp_fixargs(args))
ExecuteError: ERROR 010024: Error during conversion.
Failed to execute (ExtractByMask).


and if I *first* import arcpy and *then* import gdal, the gdal DLL could not be found:
import arcpy
from osgeo import gdal

arcpy.CheckOutExtension("Spatial")
raster = 'E:/temp/raster.img'
shapefile = 'E:/temp/shapefile.shp'

mask = arcpy.sa.ExtractByMask(raster,shapefile)
mask.save('E:/temp/test.img')

>>> 
Traceback (most recent call last):
  File "E:\temp\ivan\testing3.py", line 2, in <module>
    from osgeo import gdal
  File "C:\Python26\ArcGIS10.0\lib\site-packages\osgeo\gdal.py", line 7, in <module>
    import _gdal
ImportError: DLL load failed: The specified procedure could not be found.


Is there anyone else experiencing this, and is this due to my settings? or is there some conflict between ArcGIS 10 and gdal?

I have ArcGIS 10 build 2800 (I thought I installed SP1) + gdalwin32_1.6, and windows XP PRO 32 bit.

Since I'm lost now, any ideas would be great,
Niels

Outcomes