Hi All
What am I doing wrong in the following code:
IDL> osr = python.import('osgeo.osr')
% Loaded DLM: PYTHON27.
IDL> srs = osr.SpatialReference()
IDL> srs
<osgeo.osr.SpatialReference; proxy of <Swig Object of type 'OSRSpatialReferenceShadow *' at 0x7f60567008d0> >
IDL> srs.__doc__
Proxy of C++ OSRSpatialReferenceShadow class
IDL> srs.ImportFromProj4('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
% Python: Unknown method: "IMPORTFROMPROJ4"
% Execution halted at: $MAIN$
IDL> >>>srs.ImportFromProj4('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
% PYTHON_RUN: Exception: name 'srs' is not defined.
% Execution halted at: $MAIN$
IDL> python.run("srs.ImportFromProj4('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')")
According to the class definition of of SpatialReference [1], the method ImportFromProj4 does exist. The code works in Python on my system:
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo.osr
>>> srs = osgeo.osr.SpatialReference()
>>> srs.ImportFromProj4('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
0
>>> srs.ExportToWkt()
'PROJCS["UTM Zone 10, Northern Hemisphere",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[ "EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG", "8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG ","9108"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator "],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian ",-123],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting ",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]'
My feeling is that I don't understand how to use the IDL-Python bridge correctly yet.
Gordon
[1] http://gdal.org/python/osgeo.osr.SpatialReference-class.html
|