Even Rouault <even.rouault <at> spatialys.com> writes:
> > Brendan, > > thanks for the follow-up. I've just committed a fix so that the error > report is > hopefully clearer now: > > $ python swig/python/samples/tolatlong.py 0 0 byte.png > ERROR: Cannot import projection '' > > Even > I am struggling with this as well after coming back to this topic after a longer break. And while I first also found that some of my files do not have a projection in them, I now have identified a file that has all required data defined and still the CoordinateTransform is breaking with the above mentioned error. Here is my work process, see if you can find something suspicious: import gdal ds = gdal.Open('img.cal.map.cub') print("proj:", ds.GetProjection()) print("GeoTrans:", ds.GetGeoTransform()) x, y = gdal.ApplyGeoTransform(ds.GetGeoTransform(), 0, 0) print("X:{}, Y:{}".format(x, y)) import osr srs = osr.SpatialReference(ds.GetProjection()) print(srs.ExportToPrettyWkt()) ct = osr.CoordinateTransformation(srs, srs.CloneGeogCS()) print("CoordTrans:", ct) print(ct.TransformPoint(x, y)) This results in: proj: PROJCS["Sinusoidal Mars",GEOGCS["GCS_Mars",DATUM["D_Mars", SPHEROID["Mars",3396190,0]], PRIMEM[ "Reference_Meridian",0],UNIT["degree",0.0174532925199433]], PROJECTION["Sinusoidal "],PARAMETER["longitude_of_center",296.28065864847], PARAMETER["false_easting",0] ,PARAMETER["false_northing",0]] GeoTrans: (-4959.6267029156, 0.49556621731771, 0.0, -4803213.1200085, 0.0, -0.49556621731771) X:-4959.6267029156, Y:-4803213.1200085 PROJCS["Sinusoidal Mars", GEOGCS["GCS_Mars", DATUM["D_Mars", SPHEROID["Mars",3396190,0]], PRIMEM["Reference_Meridian",0], UNIT["degree",0.0174532925199433]], PROJECTION["Sinusoidal"], PARAMETER["longitude_of_center",296.28065864847], PARAMETER["false_easting",0], PARAMETER["false_northing",0]] CoordTrans: <osgeo.osr.CoordinateTransformation; proxy of None > --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) <ipython-input-50-9e312a3e5cc7> in <module>() 10 ct = osr.CoordinateTransformation(srs, srs.CloneGeogCS()) 11 print("CoordTrans:", ct) ---> 12 print(ct.TransformPoint(x, y)) /Users/klay6683/miniconda3/lib/python3.4/site-packages/osgeo/osr.py in TransformPoint(self, *args) 793 TransformPoint(self, double x, double y, double z = 0.0) 794 """ --> 795 return _osr.CoordinateTransformation_TransformPoint(self, *args) 796 797 def TransformPoints(self, *args): NotImplementedError: Wrong number of arguments for overloaded function 'CoordinateTransformation_TransformPoint'. Possible C/C++ prototypes are: TransformPoint(OSRCoordinateTransformationShadow *,double [3]) TransformPoint(OSRCoordinateTransformationShadow *,double [3],double,double,double) As the function is required an array with 3 elements formally (but I thought I previously handed it only 2 and it was just working fine, assuming 0 for the last element) I also tried two more versions, one with a Python list and one with that Python list embedded into a numpy array with dtype='double', all to no avail: print(ct.TransformPoint((x,y,0))) --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) <ipython-input-51-3179e52dbf67> in <module>() ----> 1 print(ct.TransformPoint((x,y,0))) /Users/klay6683/miniconda3/lib/python3.4/site-packages/osgeo/osr.py in TransformPoint(self, *args) 793 TransformPoint(self, double x, double y, double z = 0.0) 794 """ --> 795 return _osr.CoordinateTransformation_TransformPoint(self, *args) 796 797 def TransformPoints(self, *args): NotImplementedError: Wrong number of arguments for overloaded function 'CoordinateTransformation_TransformPoint'. Possible C/C++ prototypes are: TransformPoint(OSRCoordinateTransformationShadow *,double [3]) TransformPoint(OSRCoordinateTransformationShadow *,double [3],double,double,double) print(ct.TransformPoint(np.array([x,y,0],dtype='double'))) --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) <ipython-input-52-9bad892efd2f> in <module>() ----> 1 print(ct.TransformPoint(np.array([x,y,0],dtype='double'))) /Users/klay6683/miniconda3/lib/python3.4/site-packages/osgeo/osr.py in TransformPoint(self, *args) 793 TransformPoint(self, double x, double y, double z = 0.0) 794 """ --> 795 return _osr.CoordinateTransformation_TransformPoint(self, *args) 796 797 def TransformPoints(self, *args): NotImplementedError: Wrong number of arguments for overloaded function 'CoordinateTransformation_TransformPoint'. Possible C/C++ prototypes are: TransformPoint(OSRCoordinateTransformationShadow *,double [3]) TransformPoint(OSRCoordinateTransformationShadow *,double [3],double,double,double) This is my gdal.VersionInfo() output: '1110200' Any ideas? Thanks, Michael _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev