Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Overlay text in a geotiff image

Subject: Overlay text in a geotiff image

From: Romain

Date: 16 Feb, 2010 13:46:54

Message: 1 of 6

Hello,
I am trying to plot some text on a geotiff image taken from :
http://rapidfire.sci.gsfc.nasa.gov/subsets/?subset=AERONET_Barcelona.2010046.terra.2km.tif

[x, map,r,bb]=geotiffread('test.tif');
figure
geoshow(x,map,r)
textm(44,4,'this is the text');

But the last command doesn't work. It gives an error message :
" ??? Error using ==> textm
   Not a map axes. Select a map axes or use AXESM to define one. "

I might miss something very easy. I read the mapping toolbox
documentaiton but didn't find any examples.

Thanks in advance,
Romain.

Subject: Overlay text in a geotiff image

From: Steven Lord

Date: 16 Feb, 2010 14:12:26

Message: 2 of 6


"Romain" <bonne.romain@gmail.com> wrote in message
news:e44ab384-a6ed-4674-98e5-f8dd2faaa829@h2g2000yqj.googlegroups.com...
> Hello,
> I am trying to plot some text on a geotiff image taken from :
> http://rapidfire.sci.gsfc.nasa.gov/subsets/?subset=AERONET_Barcelona.2010046.terra.2km.tif
>
> [x, map,r,bb]=geotiffread('test.tif');
> figure
> geoshow(x,map,r)
> textm(44,4,'this is the text');
>
> But the last command doesn't work. It gives an error message :
> " ??? Error using ==> textm
> Not a map axes. Select a map axes or use AXESM to define one. "
>
> I might miss something very easy. I read the mapping toolbox
> documentaiton but didn't find any examples.

Either create a map axes using the AXESM function before calling TEXTM:

http://www.mathworks.com/access/helpdesk/help/toolbox/map/axesm.html

or call TEXT instead of TEXTM to add text to a regular, non-map axes.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Overlay text in a geotiff image

From: Romain

Date: 16 Feb, 2010 15:19:08

Message: 3 of 6

> Either create a map axes using the AXESM function before calling TEXTM:
> http://www.mathworks.com/access/helpdesk/help/toolbox/map/axesm.html

Thanks. Could you tell me an example how to use AXESM with
GEOTIFFREAD ?
The documentation of AXESM doesn't show any examples.
Thank you,

Subject: Overlay text in a geotiff image

From: Steven Lord

Date: 16 Feb, 2010 15:27:51

Message: 4 of 6


"Romain" <bonne.romain@gmail.com> wrote in message
news:8eef44f3-c9cf-4960-960d-db618c8208c3@15g2000yqi.googlegroups.com...
>> Either create a map axes using the AXESM function before calling TEXTM:
>> http://www.mathworks.com/access/helpdesk/help/toolbox/map/axesm.html
>
> Thanks. Could you tell me an example how to use AXESM with
> GEOTIFFREAD ?
> The documentation of AXESM doesn't show any examples.

Take a look at this page from the Mapping Toolbox documentation; it contains
a number of examples using AXESM:

http://www.mathworks.com/access/helpdesk/help/toolbox/map/f1-6032.html

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ

Subject: Overlay text in a geotiff image

From: Romain

Date: 17 Feb, 2010 09:18:44

Message: 5 of 6


> Take a look at this page from the Mapping Toolbox documentation; it contains
> a number of examples using AXESM:
> http://www.mathworks.com/access/helpdesk/help/toolbox/map/f1-6032.html

OK, I improve a bit but now get an error message.

My referencing matrix is :

r =

         0 -0.0180
    0.0254 0
   -1.0572 47.3279


The size of the image is 360 x 480
To get the latitude and longitudes limits, I calculate :

[min]=[0 0 1]*r;
[max]=[360 480 1]*r;
axesm('pcarree','MapLatLimit',[min(2) max(2)],'MapLonLimit',[min(1)
max(1)]);
geoshow(x,map,r);

The values are :
min =
   -1.0572 47.3279
max =
   11.1524 40.8528

And I get an error message :
" ??? Error using ==> refmat2vec
Row subscript must increase with latitude. "

It seems that the referencing matrix r does not match the axes. Any
ideas ? Thank you,

Subject: Overlay text in a geotiff image

From: Rob Comer

Date: 18 Feb, 2010 22:25:20

Message: 6 of 6

Romain <bonne.romain@gmail.com> wrote in message <5dded522-c55a-4c6b-a74e-185695e9a5ed@f8g2000yqn.googlegroups.com>...
>
> > Take a look at this page from the Mapping Toolbox documentation; it contains
> > a number of examples using AXESM:
> > http://www.mathworks.com/access/helpdesk/help/toolbox/map/f1-6032.html
>
> OK, I improve a bit but now get an error message.
>
> My referencing matrix is :
>
> r =
>
> 0 -0.0180
> 0.0254 0
> -1.0572 47.3279
>
>
> The size of the image is 360 x 480
> To get the latitude and longitudes limits, I calculate :
>
> [min]=[0 0 1]*r;
> [max]=[360 480 1]*r;
> axesm('pcarree','MapLatLimit',[min(2) max(2)],'MapLonLimit',[min(1)
> max(1)]);
> geoshow(x,map,r);
>
> The values are :
> min =
> -1.0572 47.3279
> max =
> 11.1524 40.8528
>
> And I get an error message :
> " ??? Error using ==> refmat2vec
> Row subscript must increase with latitude. "
>
> It seems that the referencing matrix r does not match the axes. Any
> ideas ? Thank you,

Hi,

Please try this example:
==============

R = [0 -0.0180; ...
     0.0254 0; ...
    -1.0572 47.3279];

M = 360;
N = 480;

% Determine the latitude and longitude limits

% The first pixel is _centered_ at (1,1) in the row-column system, so it
% extends from 0.5 to 1.5 in both dimensions. So the outer corner
% associated with the first pixel falls at (0.5, 0.5). Likewise, the
% outer corner associated with the last pixel falls at (M + 0.5,
% N + 0.5).

% Columns run from north to south -- because R(1,2) is negative -- so
% the following gets us the upper latitude limit.
[latlim(2) lonlim(1)] = pix2latlon(R, 0.5, 0.5);

% And this gets the lower latitude limit.
[latlim(1) lonlim(2)] = pix2latlon(R, M + 0.5, N + 0.5);

latlim

lonlim

figure('Color','white')
axesm('pcarree','MapLatLimit', latlim,'MapLonLimit', lonlim)
axis off; framem on; gridm on; mlabel on; plabel on;
setm(gca,'MLineLocation',2,'PLineLocation',2)
setm(gca,'MLabelLocation',2,'PLabelLocation',2)
tightmap

% Repeat rows and columns in the clown image to make it M-by-N
load clown
X = X([1:size(X,1) 1:(M-size(X,1))],[1:size(X,2) 1:(N-size(X,2))]);

geoshow(X, map, R)
==============

I think you should be able to adapt this to your needs. I just ran it successfully in R2009b. (Which version are you using?)

Rob Comer
Mapping Toolbox Development
The MathWorks, Inc.

Tags for this Thread

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.

Contact us