comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » IDL-Python bridge with GDAL/OGR
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
IDL-Python bridge with GDAL/OGR [message #93688] Fri, 30 September 2016 10:51 Go to previous message
Gordon Farquharson is currently offline  Gordon Farquharson
Messages: 48
Registered: December 2010
Member
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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: get data points of the contoured image
Next Topic: How to read nc variable partly?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:10:53 PDT 2025

Total time taken to generate the page: 0.00574 seconds