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

Home » Public Forums » archive » Re: Image Warp Success?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Image Warp Success? [message #69729] Tue, 09 February 2010 13:38 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
pp writes:

> Also, I noticed that if I give a sphere_radius to
> mapcoord::setmapprojection, I get a
>
> % Tag name DATUM is undefined for structure MAPCOORD.
>
> from the line (in the version I have, 628)
> self.datum.semimajor_axis = sphere_radius
>
> Which looked to me like it should have self.thisdatum, instead of
> self.datum. Or was I not using it right?

Yes, that is a problem, too. Not my day, apparently. :-(

Although any day that you understand something that previously
confused the hell out of you has to be a good day, no matter
how poor your programming skills are. :-)

Download a new version of the MapCoord object. I think your's
is pretty old. :-)

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 #69730 is a reply to message #69729] Tue, 09 February 2010 13:35 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Once this problem was fixed, I obtained what appear to be
> reasonable results from MAP_PROJ_IMAGE. My apologies for casting
> aspertion on code that possibly doesn't deserve it. I do note
> that the documenation is not clear as to what the "range"
> parameter should be, and that you only get "correct" results if
> you specify the range in UV coordinates, rather than the lat/lon
> coordinates specified in the on-line help. I learned this only

Whoa! About 10 seconds after I sent this message I just
FINALLY understood how MAP_PROJ_IMAGE works! Don't read
the documenation, you will be plenty confused. Read my
article as soon as I get it written. This routine is
not too bad, once you understand how to use it. :-)

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 #69731 is a reply to message #69730] Tue, 09 February 2010 13:16 Go to previous messageGo to next message
penteado is currently offline  penteado
Messages: 866
Registered: February 2018
Senior Member
Administrator
On Feb 9, 6:52 pm, David Fanning <n...@dfanning.com> wrote:
> My inability to get a reasonable result with MAP_PROJ_IMAGE
> has turned out to be at least partly due to an incredibly
> embarrassing error in my MapCoord object, which I use to
> work around many of the reentrant limitations of the
> MAP_PROJ_*** routines.
>
> If the desired map projection was passed into the object
> as a string (e.g., 'UTM') rather than as an index
> (e.g., 101), then the wrong map projection information
> was saved in the object. I rarely use map projection
> names, which is probably why it took me so long to discover
> this grievous error. :-(

I think I ran into that problem yesterday, but I thought it was
because I did not know the right way to use mapcoord. Since the result
kept showing the default projection, I changed from setting it by name
to setting it by number.

Also, I noticed that if I give a sphere_radius to
mapcoord::setmapprojection, I get a

% Tag name DATUM is undefined for structure MAPCOORD.

from the line (in the version I have, 628)
self.datum.semimajor_axis = sphere_radius

Which looked to me like it should have self.thisdatum, instead of
self.datum. Or was I not using it right?

Anyway, Catalyst is much appreciated. It made my widget programs much
nicer, and my life much easier.
Re: Image Warp Success? [message #69732 is a reply to message #69731] Tue, 09 February 2010 12:52 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> 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. :-(

My inability to get a reasonable result with MAP_PROJ_IMAGE
has turned out to be at least partly due to an incredibly
embarrassing error in my MapCoord object, which I use to
work around many of the reentrant limitations of the
MAP_PROJ_*** routines.

If the desired map projection was passed into the object
as a string (e.g., 'UTM') rather than as an index
(e.g., 101), then the wrong map projection information
was saved in the object. I rarely use map projection
names, which is probably why it took me so long to discover
this grievous error. :-(

In any case, this is fixed now, and I have confirmed that
the output map structure from my object and from MAP_PROJ_INIT
are identical no matter how the map projection is selected.

http://www.dfanning.com/programs/catalyst/source/coordinates /mapcoord__d
efine.pro

Once this problem was fixed, I obtained what appear to be
reasonable results from MAP_PROJ_IMAGE. My apologies for casting
aspertion on code that possibly doesn't deserve it. I do note
that the documenation is not clear as to what the "range"
parameter should be, and that you only get "correct" results if
you specify the range in UV coordinates, rather than the lat/lon
coordinates specified in the on-line help. I learned this only
by comparing the results from the results from ENVI.

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 #69742 is a reply to message #69732] Tue, 09 February 2010 04:12 Go to previous messageGo to next message
philipelson is currently offline  philipelson
Messages: 9
Registered: March 2009
Junior Member
> Has anyone ever had any success using MAP_PROJ_IMAGE to
> warp an image in one map projection into another map
> projection?


I did something similar to this recently, though not on the
projections that you want - in *theory* that shouldn't matter! You
will need to get hold of the image found at the URL below, but here is
the code:


URL = 'http://onearth.jpl.nasa.gov/wms.cgi?
request=GetMap&width=256&height=256&layers=modis &styles=&srs=EPSG:
4326&format=image/png&bbox=-30,0,70,80'

file = 'wms.cgi.png'

image = READ_IMAGE(file,r,g,b)

limit = [0, -30, 80, 70]

tileStruct = MAP_PROJ_INIT(8, LIMIT = limit)
mapStruct = MAP_PROJ_INIT('Lambert Azimuthal')

PLOT, mapStruct.uv_box[[0,2]], $
mapStruct.uv_box[[1,3]], $
/NoData, XSTYLE=5, YSTYLE=5

r = MAP_PROJ_IMAGE(reform(image[0,*,*]), tileStruct.uv_box,
MAP_STRUCTURE=mapStruct, IMAGE_STRUCTURE=tileStruct, /BILINEAR,
UVRANGE=uv)
g = MAP_PROJ_IMAGE(reform(image[1,*,*]), tileStruct.uv_box,
MAP_STRUCTURE=mapStruct, IMAGE_STRUCTURE=tileStruct, /BILINEAR,
UVRANGE=uv)
b = MAP_PROJ_IMAGE(reform(image[2,*,*]), tileStruct.uv_box,
MAP_STRUCTURE=mapStruct, IMAGE_STRUCTURE=tileStruct, /BILINEAR,
UVRANGE=uv, mask=mask)

top_right = CONVERT_COORD(uv[2], uv[3], /DATA, /TO_DEVICE)
bottom_left = CONVERT_COORD(uv[0], uv[1], /DATA, /TO_DEVICE)
img_size = (ceil(top_right - bottom_left))[0:1]

image = congrid([[[r]], [[g]], [[b]]], img_size[0], img_size[1], 3)

tv, image, uv[0], uv[1], true=3, /data

map_continents, MAP_STRUCTURE=mapStruct, /hires

map_grid, MAP_STRUCTURE=mapStruct



I hope this is helpful,

Regards,

Philip
Re: Image Warp Success? [message #69754 is a reply to message #69742] Mon, 08 February 2010 13:25 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Maxwell Peck writes:

> I gave up a long time ago. ENVI seems to work fine though, it's only
> expensive if your time isn't worth anything I guess (and sanity). If
> you really want to stick it up ITT though using GDAL with Python
> bindings is good for these sort of tasks (you can even do basic
> conversions without scripting). I definitely plan to move over to this
> once support for file formats I use is a little bit more mature.

Our Learning Python group is starting up next week. Maybe
I'll take this on as my first project. :-)

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 #69758 is a reply to message #69754] Mon, 08 February 2010 12:43 Go to previous messageGo to next message
Maxwell Peck is currently offline  Maxwell Peck
Messages: 61
Registered: February 2010
Member
> Has anyone ever had any success using MAP_PROJ_IMAGE to
> warp an image in one map projection into another map
> projection?

I gave up a long time ago. ENVI seems to work fine though, it's only
expensive if your time isn't worth anything I guess (and sanity). If
you really want to stick it up ITT though using GDAL with Python
bindings is good for these sort of tasks (you can even do basic
conversions without scripting). I definitely plan to move over to this
once support for file formats I use is a little bit more mature.

Max
Re: Image Warp Success? [message #69816 is a reply to message #69730] Wed, 10 February 2010 09:22 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> Whoa! About 10 seconds after I sent this message I just
> FINALLY understood how MAP_PROJ_IMAGE works! Don't read
> the documenation, you will be plenty confused. Read my
> article as soon as I get it written. This routine is
> not too bad, once you understand how to use it. :-)

I note this morning that the MAP_PROJ_IMAGE on-line
help on my Windows machine is different (and a LOT more
accurate) than the on-line help on my LINUX machine.
The LINUX IDL version is IDL 7.0.2 and the Windows
version is 7.1.2. So, I guess ITTVIS has noticed
the deficiency and have taken steps to fix it.

In particular, this paragraph has been added to the
description of the range parameter:

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 is the essential piece of information that I
stumbled onto yesterday and which is needed to make
this work properly.

Cheers,

David



--
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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Simultaneous write on textfile over NFS
Next Topic: Re: dereference with wildcard

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

Current Time: Wed Oct 08 15:11:38 PDT 2025

Total time taken to generate the page: 0.00640 seconds