Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: how to assign lat/lon to a 2D Earth image

Subject: how to assign lat/lon to a 2D Earth image

From: Roy Chang

Date: 03 Jan, 2008 01:42:44

Message: 1 of 5

For the below earth image

http://veimages.gsfc.nasa.gov/2430/land_ocean_ice_2048.jpg

how to assign the latitudes/longitudes to the corresponding
locations of the image? For example, if I plot a red point
on the location (lon,lat) then the corresponding location on
the image will show a red point.

Subject: Re: how to assign lat/lon to a 2D Earth image

From: Roger Stafford

Date: 03 Jan, 2008 04:23:43

Message: 2 of 5

"Roy Chang" <tigermacross@yahoo.com> wrote in message <flheik$l3b
$1@fred.mathworks.com>...
> For the below earth image
>
> http://veimages.gsfc.nasa.gov/2430/land_ocean_ice_2048.jpg
>
> how to assign the latitudes/longitudes to the corresponding
> locations of the image? For example, if I plot a red point
> on the location (lon,lat) then the corresponding location on
> the image will show a red point.
--------
  That image looks very much like a Mercator projection. If so, then longitude
and latitude values can be translated linearly into the usual x,y indices for
images. In other words, the area within a one-degree interval of longitude and
one-degree interval of latitude will the same-sized rectangle - probably a
square - throughout the entire map.

Roger Stafford

Subject: Re: how to assign lat/lon to a 2D Earth image

From: Roy Chang

Date: 03 Jan, 2008 23:21:32

Message: 3 of 5

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.

Subject: Re: how to assign lat/lon to a 2D Earth image

From: Joaquim Luis

Date: 04 Jan, 2008 02:40:19

Message: 4 of 5

"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.
>

Normally the operation you want (image registration or
georeferencing) is more complicated but in this case it's
trivial since the image is simply in lon-lat covering the
whole earth. So something like this should work

I = imread('the image'); % 'the image' is obviously
the image file name
image([-180 180],[-90 90],I)

J. Luis

Subject: Re: how to assign lat/lon to a 2D Earth image

From: Roger Stafford

Date: 04 Jan, 2008 05:37:14

Message: 5 of 5

"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

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics