GDAL reprojection error: in method 'Geometry_Transform', argument 2 of type 'OSRCoordinateTransformationShadow *'
Question: Using Python 2.7.9 with GDAL 1.11.1, with miniconda for package management --

Performing this a simple reprojection of a coordinate point causes the error
described below.

I am relatively new to GDAL, so I checked to see if the code from the [Python
GDAL/OGR 1.0 Cookbook](http://pcjericks.github.io/py-gdalogr-
cookbook/projection.html#reproject-a-geometry) produces the same issue, and it
does:

    
    
    from osgeo import ogr
    from osgeo import osr
    
    source = osr.SpatialReference()
    source.ImportFromEPSG(2927)
    
    target = osr.SpatialReference()
    target.ImportFromEPSG(4326)
    
    transform = osr.CoordinateTransformation(source, target)
    point = ogr.CreateGeometryFromWkt("POINT (1120351.57 741921.42)")
    point.Transform(transform)
    print point.ExportToWkt()
    

This is the error:

    
    
    /opt/miniconda/envs/pygeo/lib/python2.7/site-packages/osgeo/ogr.pyc in Transform(self, *args)
       4880         OGRERR_NONE on success or an error code.
       4881         """
    -> 4882         return _ogr.Geometry_Transform(self, *args)
       4883 
       4884     def GetSpatialReference(self, *args):
    
    TypeError: in method 'Geometry_Transform', argument 2 of type 'OSRCoordinateTransformationShadow *'
    

CoordinateTransform is a proxy for the C++ OSRCoordinateTransformationShadow
class, generated by SWIG. Per the [source code for
osgeo.ogr.Geometry](http://gdal.org/python/osgeo.ogr-
pysrc.html#Geometry.Transform) (what Point is), the correct types were passed
to the Transform method.

Best guess: Could this be caused by using a version of _ogr that is too old,
and so the implementation of _ogr.Geometry_Transform(self, *args) is expecting
a different? _ogr is another SWIG-generated proxy, I'm guessing for the OGR
class?


Answer: What everyone new to GDAL must learn: assign an error handler. (example:
<http://pcjericks.github.io/py-gdalogr-cookbook/gdal_general.html#install-
gdal-ogr-error-handler>)

With an error handler assigned, the output includes the explanation for the
error. In this case, it was: "Unable to load PROJ.4 library (libproj.so),
creation of OGRCoordinateTransformation failed."

Hopefully, imparting the knowledge of enabling GDAL error handling will help
others who may stumble upon this very issue.

