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:
Contour on world map

Subject: Contour on world map

From: Soumik

Date: 31 Aug, 2009 18:49:05

Message: 1 of 10

Hello,

I have a dataset of 144 x 73 form. I need to plot it in contour over a world map.The 73 latitude and 144 longitude values are as follows:
latitude= 90, 87.5, 85, 82.5, 80, 77.5, 75, 72.5, 70, 67.5, 65, 62.5, 60, 57.5,
    55, 52.5, 50, 47.5, 45, 42.5, 40, 37.5, 35, 32.5, 30, 27.5, 25, 22.5, 20,
    17.5, 15, 12.5, 10, 7.5, 5, 2.5, 0, -2.5, -5, -7.5, -10, -12.5, -15,
    -17.5, -20, -22.5, -25, -27.5, -30, -32.5, -35, -37.5, -40, -42.5, -45,
    -47.5, -50, -52.5, -55, -57.5, -60, -62.5, -65, -67.5, -70, -72.5, -75,
    -77.5, -80, -82.5, -85, -87.5, -90 ;
longitude= 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35,
    37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70,
    72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105,
    107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135,
    137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165,
    167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195,
    197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225,
    227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255,
    257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285,
    287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315,
    317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345,
    347.5, 350, 352.5, 355, 357.5 ;

When I am making a normal contour plot it is taking 144 in the y axis and 73 in the x axis. So how can I make a contour plot on a world map using the actual lat and long values?

Thank you
Soumik

Subject: Contour on world map

From: us

Date: 31 Aug, 2009 18:59:04

Message: 2 of 10

"Soumik " <suvro05@yahoo.co.in> wrote in message <h7h5v1$mso$1@fred.mathworks.com>...
> Hello,
>
> I have a dataset of 144 x 73 form. I need to plot it in contour over a world map.The 73 latitude and 144 longitude values are as follows:
> latitude= 90, 87.5, 85, 82.5, 80, 77.5, 75, 72.5, 70, 67.5, 65, 62.5, 60, 57.5,
> 55, 52.5, 50, 47.5, 45, 42.5, 40, 37.5, 35, 32.5, 30, 27.5, 25, 22.5, 20,
> 17.5, 15, 12.5, 10, 7.5, 5, 2.5, 0, -2.5, -5, -7.5, -10, -12.5, -15,
> -17.5, -20, -22.5, -25, -27.5, -30, -32.5, -35, -37.5, -40, -42.5, -45,
> -47.5, -50, -52.5, -55, -57.5, -60, -62.5, -65, -67.5, -70, -72.5, -75,
> -77.5, -80, -82.5, -85, -87.5, -90 ;
> longitude= 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35,
> 37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70,
> 72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105,
> 107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135,
> 137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165,
> 167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195,
> 197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225,
> 227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255,
> 257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285,
> 287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315,
> 317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345,
> 347.5, 350, 352.5, 355, 357.5 ;
>
> When I am making a normal contour plot it is taking 144 in the y axis and 73 in the x axis. So how can I make a contour plot on a world map using the actual lat and long values?
>
> Thank you
> Soumik

put your data into a form, which can easily be copy/pasted by CSSMers...

us

Subject: Contour on world map

From: Yuri Geshelin

Date: 31 Aug, 2009 19:40:20

Message: 3 of 10

"Soumik " <suvro05@yahoo.co.in> wrote in message <h7h5v1$mso$1@fred.mathworks.com>...
> Hello,
>
> I have a dataset of 144 x 73 form. I need to plot it in contour over a world map.The 73 latitude and 144 longitude values are as follows:
> latitude= 90, 87.5, 85, 82.5, 80, 77.5, 75, 72.5, 70, 67.5, 65, 62.5, 60, 57.5,
> 55, 52.5, 50, 47.5, 45, 42.5, 40, 37.5, 35, 32.5, 30, 27.5, 25, 22.5, 20,
> 17.5, 15, 12.5, 10, 7.5, 5, 2.5, 0, -2.5, -5, -7.5, -10, -12.5, -15,
> -17.5, -20, -22.5, -25, -27.5, -30, -32.5, -35, -37.5, -40, -42.5, -45,
> -47.5, -50, -52.5, -55, -57.5, -60, -62.5, -65, -67.5, -70, -72.5, -75,
> -77.5, -80, -82.5, -85, -87.5, -90 ;
> longitude= 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35,
> 37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70,
> 72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105,
> 107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135,
> 137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165,
> 167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195,
> 197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225,
> 227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255,
> 257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285,
> 287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315,
> 317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345,
> 347.5, 350, 352.5, 355, 357.5 ;
>
> When I am making a normal contour plot it is taking 144 in the y axis and 73 in the x axis. So how can I make a contour plot on a world map using the actual lat and long values?
>
> Thank you
> Soumik

Hi Soumik,

this works:

r = peaks(144); contour(longitude,latitude,r(1:73,:))

Or, to make longitudes <= 180, replace longitude with this:

[longitude(longitude>180)-360 longitude(longitude<=180)]

Yuri

Subject: Contour on world map

From: Soumik

Date: 31 Aug, 2009 20:19:02

Message: 4 of 10

Hello Yuri,
Can you please explain your code a bit...I am not a very efficient Matlab handler.

Thank you


"Yuri Geshelin" <geshelin@hotmail.com> wrote in message <h7h8v4$bls$1@fred.mathworks.com>...
> "Soumik " <suvro05@yahoo.co.in> wrote in message <h7h5v1$mso$1@fred.mathworks.com>...
> > Hello,
> >
> > I have a dataset of 144 x 73 form. I need to plot it in contour over a world map.The 73 latitude and 144 longitude values are as follows:
> > latitude= 90, 87.5, 85, 82.5, 80, 77.5, 75, 72.5, 70, 67.5, 65, 62.5, 60, 57.5,
> > 55, 52.5, 50, 47.5, 45, 42.5, 40, 37.5, 35, 32.5, 30, 27.5, 25, 22.5, 20,
> > 17.5, 15, 12.5, 10, 7.5, 5, 2.5, 0, -2.5, -5, -7.5, -10, -12.5, -15,
> > -17.5, -20, -22.5, -25, -27.5, -30, -32.5, -35, -37.5, -40, -42.5, -45,
> > -47.5, -50, -52.5, -55, -57.5, -60, -62.5, -65, -67.5, -70, -72.5, -75,
> > -77.5, -80, -82.5, -85, -87.5, -90 ;
> > longitude= 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35,
> > 37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70,
> > 72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105,
> > 107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135,
> > 137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165,
> > 167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195,
> > 197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225,
> > 227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255,
> > 257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285,
> > 287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315,
> > 317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345,
> > 347.5, 350, 352.5, 355, 357.5 ;
> >
> > When I am making a normal contour plot it is taking 144 in the y axis and 73 in the x axis. So how can I make a contour plot on a world map using the actual lat and long values?
> >
> > Thank you
> > Soumik
>
> Hi Soumik,
>
> this works:
>
> r = peaks(144); contour(longitude,latitude,r(1:73,:))
>
> Or, to make longitudes <= 180, replace longitude with this:
>
> [longitude(longitude>180)-360 longitude(longitude<=180)]
>
> Yuri

Subject: Contour on world map

From: Soumik

Date: 31 Aug, 2009 22:59:05

Message: 5 of 10

Hello Yuri,
Can you please explain your code a bit...I am not a very efficient Matlab handler.

Thank you


"Yuri Geshelin" <geshelin@hotmail.com> wrote in message <h7h8v4$bls$1@fred.mathworks.com>...
> "Soumik " <suvro05@yahoo.co.in> wrote in message <h7h5v1$mso$1@fred.mathworks.com>...
> > Hello,
> >
> > I have a dataset of 144 x 73 form. I need to plot it in contour over a world map.The 73 latitude and 144 longitude values are as follows:
> > latitude= 90, 87.5, 85, 82.5, 80, 77.5, 75, 72.5, 70, 67.5, 65, 62.5, 60, 57.5,
> > 55, 52.5, 50, 47.5, 45, 42.5, 40, 37.5, 35, 32.5, 30, 27.5, 25, 22.5, 20,
> > 17.5, 15, 12.5, 10, 7.5, 5, 2.5, 0, -2.5, -5, -7.5, -10, -12.5, -15,
> > -17.5, -20, -22.5, -25, -27.5, -30, -32.5, -35, -37.5, -40, -42.5, -45,
> > -47.5, -50, -52.5, -55, -57.5, -60, -62.5, -65, -67.5, -70, -72.5, -75,
> > -77.5, -80, -82.5, -85, -87.5, -90 ;
> > longitude= 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35,
> > 37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60, 62.5, 65, 67.5, 70,
> > 72.5, 75, 77.5, 80, 82.5, 85, 87.5, 90, 92.5, 95, 97.5, 100, 102.5, 105,
> > 107.5, 110, 112.5, 115, 117.5, 120, 122.5, 125, 127.5, 130, 132.5, 135,
> > 137.5, 140, 142.5, 145, 147.5, 150, 152.5, 155, 157.5, 160, 162.5, 165,
> > 167.5, 170, 172.5, 175, 177.5, 180, 182.5, 185, 187.5, 190, 192.5, 195,
> > 197.5, 200, 202.5, 205, 207.5, 210, 212.5, 215, 217.5, 220, 222.5, 225,
> > 227.5, 230, 232.5, 235, 237.5, 240, 242.5, 245, 247.5, 250, 252.5, 255,
> > 257.5, 260, 262.5, 265, 267.5, 270, 272.5, 275, 277.5, 280, 282.5, 285,
> > 287.5, 290, 292.5, 295, 297.5, 300, 302.5, 305, 307.5, 310, 312.5, 315,
> > 317.5, 320, 322.5, 325, 327.5, 330, 332.5, 335, 337.5, 340, 342.5, 345,
> > 347.5, 350, 352.5, 355, 357.5 ;
> >
> > When I am making a normal contour plot it is taking 144 in the y axis and 73 in the x axis. So how can I make a contour plot on a world map using the actual lat and long values?
> >
> > Thank you
> > Soumik
>
> Hi Soumik,
>
> this works:
>
> r = peaks(144); contour(longitude,latitude,r(1:73,:))
>
> Or, to make longitudes <= 180, replace longitude with this:
>
> [longitude(longitude>180)-360 longitude(longitude<=180)]
>
> Yuri

Subject: Contour on world map

From: us

Date: 31 Aug, 2009 23:24:21

Message: 6 of 10

"Soumik " <suvro05@yahoo.co.in> wrote in message <h7hb7m$a2a$1@fred.mathworks.com>...

> > r = peaks(144); contour(longitude,latitude,r(1:73,:))
> > Or, to make longitudes <= 180, replace longitude with this:
> > [longitude(longitude>180)-360 longitude(longitude<=180)]
> > Yuri

> Hello Yuri,
> Can you please explain your code a bit...I am not a very efficient Matlab handler.

a hint:
- or is it the same hint shown to your in your last OP...

     help contour;

us

Subject: Contour on world map

From: Yuri Geshelin

Date: 1 Sep, 2009 00:18:18

Message: 7 of 10

"Soumik " <suvro05@yahoo.co.in> wrote in message <h7hkjp$leq$1@fred.mathworks.com>...
> Hello Yuri,
> Can you please explain your code a bit...I am not a very efficient Matlab handler.
>
> Thank you
>

All right, you said in your 1st post that you had ended up with 144 points in the y axis and 73 in the x axis. This is the opposite to what you want. Please provide your code, with which you got it wrong. We will then compare it with mine, and you will be able to fix your mistake and understand my code.

Yuri

Subject: Contour on world map

From: Soumik

Date: 1 Sep, 2009 00:57:19

Message: 8 of 10

Hi,

Here is my code:
 clc;
clear all;

data = dlmread('janMeanLtm.mat');
 slp=data(:,4);


 
 x= -180:2.5:180;
 y=linspace(-90,90,length(x))';
 
 [x,y,zw]=griddata(data(:,2),data(:,1),slp,x,y,'linear');
 
 % === Plotting filled contour of data ====
 contourf(x,y,zw,'ShowText','on');
 hold on;
 % ====== Show world map on the same plot =====
 geoshow(latitude,longiitude','FaceColor', 'none');
 hold off;

But this code is telling that it cannot read the input file. But Matlab can read this same input file while making a simple contour plot without lat long. I have never used Matlab or any mapping software before so this is confusing me very much.Please help me.

thanking you
Soumik




"Yuri Geshelin" <geshelin@hotmail.com> wrote in message <h7hp8a$elp$1@fred.mathworks.com>...
> "Soumik " <suvro05@yahoo.co.in> wrote in message <h7hkjp$leq$1@fred.mathworks.com>...
> > Hello Yuri,
> > Can you please explain your code a bit...I am not a very efficient Matlab handler.
> >
> > Thank you
> >
>
> All right, you said in your 1st post that you had ended up with 144 points in the y axis and 73 in the x axis. This is the opposite to what you want. Please provide your code, with which you got it wrong. We will then compare it with mine, and you will be able to fix your mistake and understand my code.
>
> Yuri

Subject: Contour on world map

From: Yuri Geshelin

Date: 1 Sep, 2009 13:46:00

Message: 9 of 10

"Soumik " <suvro05@yahoo.co.in> wrote in message <h7hrhf$6eg$1@fred.mathworks.com>...
> Hi,
>
> Here is my code:
> clc;
> clear all;
>
> data = dlmread('janMeanLtm.mat');
> slp=data(:,4);
>
>
>
> x= -180:2.5:180;
> y=linspace(-90,90,length(x))';
>
> [x,y,zw]=griddata(data(:,2),data(:,1),slp,x,y,'linear');
>
> % === Plotting filled contour of data ====
> contourf(x,y,zw,'ShowText','on');
> hold on;
> % ====== Show world map on the same plot =====
> geoshow(latitude,longiitude','FaceColor', 'none');
> hold off;
>
> But this code is telling that it cannot read the input file. But Matlab can read this same input file while making a simple contour plot without lat long. I have never used Matlab or any mapping software before so this is confusing me very much.Please help me.
>
> thanking you
> Soumik
>
>
>
>
> "Yuri Geshelin" <geshelin@hotmail.com> wrote in message <h7hp8a$elp$1@fred.mathworks.com>...
> > "Soumik " <suvro05@yahoo.co.in> wrote in message <h7hkjp$leq$1@fred.mathworks.com>...
> > > Hello Yuri,
> > > Can you please explain your code a bit...I am not a very efficient Matlab handler.
> > >
> > > Thank you
> > >
> >
> > All right, you said in your 1st post that you had ended up with 144 points in the y axis and 73 in the x axis. This is the opposite to what you want. Please provide your code, with which you got it wrong. We will then compare it with mine, and you will be able to fix your mistake and understand my code.
> >
> > Yuri

Soumik,

1) You cannot read file janMeanLtm.mat, because DLMREAD is for reading ASCII files. For a *.mat file, use LOAD (see help LOAD).
2) I do not know what GEOSHOW does (there is no such command in my version of matlab), but my guess is that you should write

geoshow(longitude,latitude,'FaceColor', 'none');

The point is, longitude goes first. This is why you may have 144 points in the y axis and 73 in the x axis. I do not know Whether or not longitude needs to be transposed as in your example (i.e. followed by apostrophe).

Also, chances are that geoshow replaces the output of your CONTOUR command or sits on top of it so that you do not see it.

Now to my code. Did you try it? Let us go over it. See HELP for ea. command.

> r = peaks(144);

This generates a 2-D array r whose size is 144 x 144. We shall use it as an example, because I do not have access to your data.

> contour(longitude,latitude,r(1:73,:))

r(1:73,:) is a subset of r whose size is 73 rows by 144 cols. The above CONTOUR command will make a contour plot with X-axis going from 0 to 357.5

If you use [longitude(longitude>180)-360 longitude(longitude<=180)] instead of just longitude, this will be the same except X-axis will go from 0 to 180, then back to 0 in the negative part of the circumference.

-----

By the way: what is slp - sea level pressure?

Subject: Contour on world map

From: Soumik

Date: 2 Sep, 2009 02:38:04

Message: 10 of 10

Hi Yuri,
yes Slp is sea level pressure. Load command is not working also.I have tried it.I don't know why it is behaving like that.

Thank you
Soumik



"Yuri Geshelin" <geshelin@hotmail.com> wrote in message <h7j8io$iig$1@fred.mathworks.com>...
> "Soumik " <suvro05@yahoo.co.in> wrote in message <h7hrhf$6eg$1@fred.mathworks.com>...
> > Hi,
> >
> > Here is my code:
> > clc;
> > clear all;
> >
> > data = dlmread('janMeanLtm.mat');
> > slp=data(:,4);
> >
> >
> >
> > x= -180:2.5:180;
> > y=linspace(-90,90,length(x))';
> >
> > [x,y,zw]=griddata(data(:,2),data(:,1),slp,x,y,'linear');
> >
> > % === Plotting filled contour of data ====
> > contourf(x,y,zw,'ShowText','on');
> > hold on;
> > % ====== Show world map on the same plot =====
> > geoshow(latitude,longiitude','FaceColor', 'none');
> > hold off;
> >
> > But this code is telling that it cannot read the input file. But Matlab can read this same input file while making a simple contour plot without lat long. I have never used Matlab or any mapping software before so this is confusing me very much.Please help me.
> >
> > thanking you
> > Soumik
> >
> >
> >
> >
> > "Yuri Geshelin" <geshelin@hotmail.com> wrote in message <h7hp8a$elp$1@fred.mathworks.com>...
> > > "Soumik " <suvro05@yahoo.co.in> wrote in message <h7hkjp$leq$1@fred.mathworks.com>...
> > > > Hello Yuri,
> > > > Can you please explain your code a bit...I am not a very efficient Matlab handler.
> > > >
> > > > Thank you
> > > >
> > >
> > > All right, you said in your 1st post that you had ended up with 144 points in the y axis and 73 in the x axis. This is the opposite to what you want. Please provide your code, with which you got it wrong. We will then compare it with mine, and you will be able to fix your mistake and understand my code.
> > >
> > > Yuri
>
> Soumik,
>
> 1) You cannot read file janMeanLtm.mat, because DLMREAD is for reading ASCII files. For a *.mat file, use LOAD (see help LOAD).
> 2) I do not know what GEOSHOW does (there is no such command in my version of matlab), but my guess is that you should write
>
> geoshow(longitude,latitude,'FaceColor', 'none');
>
> The point is, longitude goes first. This is why you may have 144 points in the y axis and 73 in the x axis. I do not know Whether or not longitude needs to be transposed as in your example (i.e. followed by apostrophe).
>
> Also, chances are that geoshow replaces the output of your CONTOUR command or sits on top of it so that you do not see it.
>
> Now to my code. Did you try it? Let us go over it. See HELP for ea. command.
>
> > r = peaks(144);
>
> This generates a 2-D array r whose size is 144 x 144. We shall use it as an example, because I do not have access to your data.
>
> > contour(longitude,latitude,r(1:73,:))
>
> r(1:73,:) is a subset of r whose size is 73 rows by 144 cols. The above CONTOUR command will make a contour plot with X-axis going from 0 to 357.5
>
> If you use [longitude(longitude>180)-360 longitude(longitude<=180)] instead of just longitude, this will be the same except X-axis will go from 0 to 180, then back to 0 in the negative part of the circumference.
>
> -----
>
> By the way: what is slp - sea level pressure?

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