Re: Image Warp Success? [message #69795 is a reply to message #69759] |
Thu, 11 February 2010 21:52   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
pfp writes:
> This may be related to a question I had this week: how can I use plot
> with locations expressed in latitude and longitude, if map_set was not
> used? From what I could find out, it seems that plot only uses !map to
> know the projection. What I wanted to do was plot lines on a Catalyst
> drawwidget that used a mapcoord to set the projection (to warp a
> background image).
>
> The way I found to do it was to get the map structure from the
> mapcoord object, and give it map_proj_forward, to convert lat/lon to
> UV coordinates. Then I plot on top of the image, setting the plot
> range to the values in the uv_box field of the map structure. This
> seems to give the right result, but I am unsure that this is the most
> proper way to do it, particularly because I am not yet very familiar
> with how the Catalyst draw, image and coordinate objects interact.
Yes, my best map projection advice is to STOP thinking in
latitude/longitude space. It just totally screws you up. :-)
What you want to think about is the map projection grid,
or what IDL calls UV space, and what almost everyone else
calls "Cartesian" or XY space. And don't even think about
using Map_Set. You want to be using the Map_Proj_*** routines.
And even those won't work worth a damn if you are trying
to do something interactively. Then I think the only usable
thing around is the MapCoord object from the Catalyst Library,
which can work around the problems with Map_Proj_Init and
it's spooky action-at-a-distance "feature."
The projected grid space is nice because it is regular
and rectangular, just like a plot! Which means if you
set your plot data space up to reflect your XY coordinate
grid, then things just go onto the map or image naturally.
MapCoord, of course, makes setting all this up extremely
simple. Just call its draw method and there you have it.
You use MAP_PROJ_INVERSE and MAP_PROJ_FORWARD to convert
back and forth from lat/lon to XY coordinates. Easy!
Map_Grid and Map_Continents can also draw onto the XY grid
if they are given a map structure derived from Map_Proj_Init.
So you don't have to do anything hard to draw map grids and
outlines. Station locations or cities or anything else you
want to draw on the plot are just PLOTS calls (usually
after converting lat/lon locations to XY with Map_Proj_Forward).
The Coyote routine GeoCoord can read a GeoTIFF image and
produce a MapCoord object that is all set up for you to
navigate your image. I'll probably write something similar
this weekend for netCDF files containing map projection
information ahead of a map projection talk I am giving at
the IDL User's Group meeting in a week or so.
I expect the presentation will be available on-line shortly
after the talk.
Cheers,
David
P.S. And, oh, don't forget to flip your image in the vertical
direction. Everyone in the world except IDL assumes the (0,0)
point is in the upper left corner! Use REVERSE for this, not
!Order or life will never make any sense to you. :-)
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|