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

Home » Public Forums » archive » Re: I'm doing something wrong with map_image
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: I'm doing something wrong with map_image [message #76371] Tue, 31 May 2011 21:22 Go to next message
almost_like_a_metapho is currently offline  almost_like_a_metapho
Messages: 8
Registered: May 2011
Junior Member
David,

Thank you very, very much for that help and example. I will try it out
tomorrow morning!

N
Re: I'm doing something wrong with map_image [message #76373 is a reply to message #76371] Tue, 31 May 2011 20:48 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
almost_like_a_metaphor writes:

> OK, from your example, what I want to display is a window that zooms
> in on just that blue box - where the coordinates of the box bound the
> window. Since I'm using simple cylindrical projection, I thought I
> could get away with just putting the image as a background to a plot
> window, as long as the axes and image corners aligned. I think my
> issue is that I was insisting on thinking of it as a data plot with an
> image background, and I really need to think of it as a displayed map
> image with shapes overplotted.
>
> So, if my base image is a global map, and all I want to do is take one
> 3x3 degree piece of it, display that, and plot my grid lines and data-
> overlay on it, do I have to create a small, subsampled "image" from
> your example above? Or can I simply display a smaller part of the
> image? in cgimage, image[lonrange,latrange]? Though in that case I
> think I'll have to convert my lat/lon ranges to image coordinates.

Let's suppose that each pixel represents 0.12 degree of latitude
or longitude (i.e., 360/3000. or 180/1500.) We can make a longitude
and latitude vector, like this:

lon = Scale_Vector(Findgen(3000), -180, 180)
lat = Scale_Vector(Findgen(1500), -90, 90)

Now, which indices in the longitude vector represents, say, 0 and 20
degrees of longitude? We can use Value_Locate to find out:

Print, Value_Locate(lon, [0,20])
1499 1666

We do the same thing with the latitude vector.

Print, Value_Locate(lat, [0,20])
749 916

Is this right?

Print, lon[[1499,1666]]
-0.0600128 19.9867

Print, lat[[749,916]]
-0.0600433 19.9933

Pretty close. So, we just zoom into this portion of
the image and set the map projection space up accordingly.

image = congrid(shift(cgDemoData(7), 180, 0), 3000, 1500)
subimage = image[1499:1666, 749:916]
cgLoadCT, 0
cgimage, subimage, /keep, position=p
map_set, /noerase, position=p, /cylindrical, $
limit=[-0.0600433, -0.0600128, 19.9933, 19.9867]
map_continents
map_grid
plots, 10, 10, psym=4, color=cgcolor('yellow')

Cheers,

David





--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: I'm doing something wrong with map_image [message #76374 is a reply to message #76373] Tue, 31 May 2011 18:05 Go to previous messageGo to next message
almost_like_a_metapho is currently offline  almost_like_a_metapho
Messages: 8
Registered: May 2011
Junior Member
On May 31, 6:05 pm, David Fanning <n...@idlcoyote.com> wrote:

> Here is an example. Suppose this image is map projected
> (I'm not sure it is):
>
> cgloadct, 0
> image = congrid(shift(cgDemoData(7), 180, 0), 3000, 1500)
> cgimage, image, /keep, position=p
> map_set, /noerase, position=p
> map_grid
> map_continents
> plots, [20, 20, 0, 0, 20], [20, 0, 0, 20, 20], color=cgcolor('blue')
> plots, 10, 10, psym=4, color=cgcolor('yellow')
>
> Cheers,
>
> David
>

OK, from your example, what I want to display is a window that zooms
in on just that blue box - where the coordinates of the box bound the
window. Since I'm using simple cylindrical projection, I thought I
could get away with just putting the image as a background to a plot
window, as long as the axes and image corners aligned. I think my
issue is that I was insisting on thinking of it as a data plot with an
image background, and I really need to think of it as a displayed map
image with shapes overplotted.

So, if my base image is a global map, and all I want to do is take one
3x3 degree piece of it, display that, and plot my grid lines and data-
overlay on it, do I have to create a small, subsampled "image" from
your example above? Or can I simply display a smaller part of the
image? in cgimage, image[lonrange,latrange]? Though in that case I
think I'll have to convert my lat/lon ranges to image coordinates.
Re: I'm doing something wrong with map_image [message #76375 is a reply to message #76374] Tue, 31 May 2011 15:05 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
almost_like_a_metaphor writes:

> I have a map image in cylindrical projection (so basically the sides
> of my map are lat-90 to 90 and lon -180 to 180), so I'm using map_set
> with /cylindrical. The image, is around 3000x1500 pixels
>
> I want to plot data on a small 3x3 degree slice of this map, say
> centered on lat=10, lon=10. I can set my map_set properly, but my
> map_image does not seem to be doing what I want it to. I want to get
> that 3x3 slice of the image displayed, place my map_grid over it, then
> plot my points, and I can't.
>
> It's got to be a gloriously simple thing that I'm missing.

Here is an example. Suppose this image is map projected
(I'm not sure it is):

cgloadct, 0
image = congrid(shift(cgDemoData(7), 180, 0), 3000, 1500)
cgimage, image, /keep, position=p
map_set, /noerase, position=p
map_grid
map_continents
plots, [20, 20, 0, 0, 20], [20, 0, 0, 20, 20], color=cgcolor('blue')
plots, 10, 10, psym=4, color=cgcolor('yellow')

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: I'm doing something wrong with map_image [message #76376 is a reply to message #76375] Tue, 31 May 2011 14:41 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
almost_like_a_metaphor writes:

> The image is map projected, yes, but at 3000x1500, one pixel is some
> fraction of a degree. ANd my data locations are at some other
> fractional degree values.

So? What does this matter? I presume you don't have a
display this large, do you?

> I wanted to take a chunk of the map, plot the grid lines over it, and
> then my data outline. I have coordinates for that, and can do plots or
> polyfill pretty easily. The issue I'm having is aligning the grid with
> my image.

Well, the grid uses latitude and longitude values
just like whatever it is you are putting on the map
with PlotS or Polyfill. I don't understand how you
could be having problems "aligning" it, unless I don't
understand what "aligning" means in this context.

> In my fondest wishes, I'd want to have the image slice
> displayed in the frame of my map_grid grid, which I can then plot the
> grid lines and data outline on top of.

I'm not sure what you mean by "image slice". Do you mean a
subset of your image? What is the "frame of the map grid"?

You talk as if you were working with rectangles, which
of course map projections aren't. Perhaps you want to be
working in projected meter space, rather than lat/lon
space, where rectangles make a lot more sense. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: I'm doing something wrong with map_image [message #76377 is a reply to message #76376] Tue, 31 May 2011 14:33 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
almost_like_a_metaphor writes:

> I"m guessing I'm doing something bass ackwards here.

Well, if you were brave enough to show us the
code, we could probably figure out exactly
what it is you are doing. :-)

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: I'm doing something wrong with map_image [message #76378 is a reply to message #76377] Tue, 31 May 2011 14:31 Go to previous messageGo to next message
almost_like_a_metapho is currently offline  almost_like_a_metapho
Messages: 8
Registered: May 2011
Junior Member
On May 31, 5:10 pm, David Fanning <n...@idlcoyote.com> wrote:
>
> Why are you using Map_Image? Your image, you say, is
> in a map projection already. You certainly don't want
> to warp it again.
>
> Without seeing your code, it is hard to say what
> simple thing you are missing. But generally, once
> you have a map coordinate system set up, drawing on
> top of it is as simple as specifying your locations in
> latitude and longitude coordinates.
>
> Cheers,
>
> David

The image is map projected, yes, but at 3000x1500, one pixel is some
fraction of a degree. ANd my data locations are at some other
fractional degree values.

I wanted to take a chunk of the map, plot the grid lines over it, and
then my data outline. I have coordinates for that, and can do plots or
polyfill pretty easily. The issue I'm having is aligning the grid with
my image. In my fondest wishes, I'd want to have the image slice
displayed in the frame of my map_grid grid, which I can then plot the
grid lines and data outline on top of.

I"m guessing I'm doing something bass ackwards here.
Re: I'm doing something wrong with map_image [message #76380 is a reply to message #76378] Tue, 31 May 2011 14:10 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
almost_like_a_metaphor writes:

> I have a map image in cylindrical projection (so basically the sides
> of my map are lat-90 to 90 and lon -180 to 180), so I'm using map_set
> with /cylindrical. The image, is around 3000x1500 pixels
>
> I want to plot data on a small 3x3 degree slice of this map, say
> centered on lat=10, lon=10. I can set my map_set properly, but my
> map_image does not seem to be doing what I want it to. I want to get
> that 3x3 slice of the image displayed, place my map_grid over it, then
> plot my points, and I can't.
>
> It's got to be a gloriously simple thing that I'm missing.

Probably. :-)

Why are you using Map_Image? Your image, you say, is
in a map projection already. You certainly don't want
to warp it again.

Without seeing your code, it is hard to say what
simple thing you are missing. But generally, once
you have a map coordinate system set up, drawing on
top of it is as simple as specifying your locations in
latitude and longitude coordinates.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: I'm doing something wrong with map_image [message #76449 is a reply to message #76373] Wed, 01 June 2011 16:32 Go to previous message
almost_like_a_metapho is currently offline  almost_like_a_metapho
Messages: 8
Registered: May 2011
Junior Member
Solution is working like a charm.

At some point I'm going to have to figure out if I can read in a small
portion of a large image, to save on i/o. Assoc might do it, if I
understand assoc correctly. (e.g. a 36000 x 18000 cylindrical
projection image (with .01 degrees per pixel, of which I'd like to
read in only a 2x2 degree square).

N
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: How to make hidden Graphics?
Next Topic: I'm doing something wrong with map_image

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

Current Time: Wed Oct 08 13:42:44 PDT 2025

Total time taken to generate the page: 0.00520 seconds