Path: news.mathworks.com!not-for-mail
From: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
Newsgroups: comp.soft-sys.matlab
Subject: Re: how to assign lat/lon to a 2D Earth image
Date: Fri, 4 Jan 2008 05:37:14 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 35
Message-ID: <flkgma$jef$1@fred.mathworks.com>
References: <flheik$l3b$1@fred.mathworks.com> <flho0f$a44$1@fred.mathworks.com> <fljqls$ian$1@fred.mathworks.com>
Reply-To: "Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1199425034 19919 172.30.248.37 (4 Jan 2008 05:37:14 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 4 Jan 2008 05:37:14 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:444287


"Roy Chang" <tigermacross@yahoo.com> wrote in message <fljqls$ian
$1@fred.mathworks.com>...
> Hi,
> Could you please show me which commands I can use to load
> the image file, assign the lat/lon, draw the figure, and
> plot the result as I mentioned?
> Thanks a lot. 
---------
  Roy, I cannot advise you as to loading images, drawing the figure, or 
plotting, since I don't have the imaging toolbox on my matlab version.  I can 
only indicate the conversion from latitude and longitude values to the 
corresponding pixel coordinates of your image.  You will note that in doing 
so I am assuming that the projection in this image is actually a Mercator 
projection as I guessed earlier in this thread, and that the image covers the 
entire earth from pole to pole and east to west, as it seems to do.

  Let it be understood that 'lat' and 'long' are values that express earth's 
latitude and longitude in degrees and fractions of a degree (not in minutes 
and seconds,) with the understanding that latitude south and longitude west 
values are to be negative.  Thus 'lat' ranges from -90 to +90 and 'long' 
ranges from -180 to +180.  Since your image is 1024 by 2048 pixels, and 
since the Greenwich prime meridian is apparently located at the east/west 
center of the image, the conversion to pixel coordinates can be expressed by:

 f = 1-2*eps; % Keep indices within bounds
 row = ceil(512-lat*1024/180*f);
 col = ceil(1024+long*2048/360*f);

  For example, Mt. Whitney in the Sierra Nevada mountains is located at 
latitude 36 deg, 34', 42.78" N and longitude 118 deg, 17', 32.604" W which 
would make lat = 36.57855 and long = -118.29239.  By the above 
conversion this would lie within the pixel with coordinates (304,352).

Roger Stafford