Re: Keywords and properties (in function graphics) [message #87489 is a reply to message #87488] |
Fri, 07 February 2014 12:13   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Gordon Farquharson writes:
>
> Hi All
>
> The IDL documentation states that keywords are applied only during the initial creation of the graphic, whereas properties can be set as keywords to the function during creation, or retrieved or changed using the "." notation after creation (e.g., [1]).
>
> Below is a simple program to display an image using a map projection. In the first case (im1), I set all keywords and properties in the function call. In the second case (im2), I only set keywords in the function call, and set properties after the function call.
>
> ---
> file1 = FILEPATH('Night.jpg', SUBDIRECTORY=['examples','data'])
>
> ret = query_jpeg(file1, info)
>
> lon = findgen(info.dimensions[0]) / info.dimensions[0] * 360. - 180.
> lat = findgen(info.dimensions[1]) / info.dimensions[1] * 180. - 90.
>
> read_jpeg, file1, data
>
> im1 = image(data, lon, lat, DIMENSIONS=[1024,512], MARGIN=0., $
> GRID_UNITS="degrees", MAP_PROJECTION="Mollweide")
>
> im2 = image(data, lon, lat, DIMENSIONS=[1024,512], MARGIN=0.)
>
> im2.grid_units = "degrees"
> im2.map_projection = "Mollweide"
>
> END
> ---
>
> im1 displays the image as I would expect (warped to the map projection). However, IDL returns the following error when the map_projection property is set for im2.
>
> % Unable to retrieve map projection.
> % Execution halted at: $MAIN$ 16 /home/gordon/tmp/test_map.pro
>
> For reference, line 16 is
>
> im2.map_projection = "Mollweide"
>
> Why? Specifically, why I can't change the map projection *property* after the image has been created?
This probably *would* work if the image *had* a map projection object to
change. But, you didn't create this image with a map projection object,
so you can't exactly change what isn't there. You can check to see if
the image *has* a map projection object with the MAPPROJECTION property:
IF im2.mapprojection EQ !Null THEN Print, 'No map projection here!'
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|