Image Warp Success? [message #69759] |
Mon, 08 February 2010 12:30  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Folks,
Has anyone ever had any success using MAP_PROJ_IMAGE to
warp an image in one map projection into another map
projection?
Given what I know about the non-reentrant nature of the
MAP_PROJ_*** routines, I can't image this ever working
properly, but I thought I would give it a try. I have
an image in a UTM map projection that I want to convert
to a Lambert Equal Area projection. The result looks
like a disaster. I'd pursue this further if someone
could give me hope. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thue. ("Perhaps thos speakest truth.")
|
|
|
Re: Image Warp Success? [message #69792 is a reply to message #69759] |
Fri, 12 February 2010 03:21  |
penteado
Messages: 866 Registered: February 2018
|
Senior Member Administrator |
|
|
Thanks for the tips.
So it ends up similar to the way to plot things over imap (first
convert to UV with the map structure). But in the case of imap it
would be much more useful if it it had a way to provide the plot
locations in lat/on, so that it could update the plot when the
projection gets changed on its interface, as it does with the images
it warps.
On Feb 12, 3:52 am, David Fanning <n...@dfanning.com> wrote:
> 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.")
|
|
|
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.")
|
|
|
Re: Image Warp Success? [message #69796 is a reply to message #69759] |
Thu, 11 February 2010 20:43  |
pfp
Messages: 12 Registered: July 2009
|
Junior Member |
|
|
On Feb 10, 3:22 pm, David Fanning <n...@dfanning.com> wrote:
> If you are warping Image from one map projection to
> another (that is, if you provide a value for the
> IMAGE_STRUCTURE keyword), then Range is a four-element
> array specifying the Cartesian (UV) range. In this case,
> Range must be provided and has the format
> [Umin, Vmin, Umax, Vmax].
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.
|
|
|