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

Home » Public Forums » archive » Any way to initialize mapping in IDL with WKT or a Proj.4 string?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Any way to initialize mapping in IDL with WKT or a Proj.4 string? [message #93692 is a reply to message #93685] Fri, 30 September 2016 14:31 Go to previous messageGo to previous message
Gordon Farquharson is currently offline  Gordon Farquharson
Messages: 48
Registered: December 2010
Member
OK, so here is a solution. It can be extended to deal with any projection IDL knows about. Thank you, Exelis/Harris for implementing the IDL-Python bridge. Very useful.

For this solution to work, you need to have the IDL-Python bridge working and have the Python API for GDAL/OGR installed.

FUNCTION map_proj_init_proj4, proj4_string

compile_opt IDL2, LOGICAL_PREDICATE, STRICTARRSUBS

osr = python.import('osgeo.osr')
srs = osr.SpatialReference()
IF osr.SpatialReference.ImportFromProj4(srs, proj4_string) NE 0 THEN BEGIN
message, 'error importing from Proj.4 string'
ENDIF

CASE 1 OF

proj4_string.matches('\+proj=utm'): BEGIN
semimajor_axis = osr.SpatialReference.GetSemiMajor(srs)
semiminor_axis = osr.SpatialReference.GetSemiMinor(srs)
utm_zone = osr.SpatialReference.GetUTMZone(srs)
map = map_proj_init(101, $
SEMIMAJOR_AXIS=semimajor_axis, $
SEMIMINOR_AXIS=semiminor_axis, $
ZONE=utm_zone)
END

ELSE: BEGIN
message, 'projection not recognized'
END

ENDCASE

return, map

END

Usage:

IDL> map_struct = map_proj_init_proj4('+proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs')
IDL> print, map_proj_forward(-122, 42, MAP=map_struct), FORMAT='(2(F20.9))'
582818.069248419 4650259.847758290

(The UTM/GCTP bug [1] seems to be fixed in IDL 8.5.1.)

Gordon

[1] http://www.idlcoyote.com/map_tips/utmwrong.php
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Increments and Decrements
Next Topic: Re: Speed does matter

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

Current Time: Wed Oct 08 13:59:29 PDT 2025

Total time taken to generate the page: 0.00363 seconds