Got Questions? Get Answers.
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 plot using m_map

Subject: Contour plot using m_map

From: Phil Ashton

Date: 13 Jun, 2011 12:26:05

Message: 1 of 14

Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...

I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.

Using the following i can produce the map but none of the data held in z is appearing???

...

m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
m_coast('patch',[1 .9 .7]);
m_tbase('contourf',[x:y:z];
m_grid('box','fancy','tickdir','in');

( x, y and z are all the same size)

ANy help is greatly appreciated

Subject: Contour plot using m_map

From: flash

Date: 13 Jun, 2011 12:38:04

Message: 2 of 14

"flash" wrote in message <it4vkt$hfr$1@newscl01ah.mathworks.com>...
> Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
>
> I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
>
> Using the following i can produce the map but none of the data held in z is appearing???
>
> ...
>
> m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> m_coast('patch',[1 .9 .7]);
> m_tbase('contourf',[x:y:z];
> m_grid('box','fancy','tickdir','in');
>
> ( x, y and z are all the same size)
>
> ANy help is greatly appreciated

How do i associate the values held in x and y with the Long and Lat values of the grid?

Any ideas??

Subject: Contour plot using m_map

From: flash

Date: 13 Jun, 2011 13:16:02

Message: 3 of 14

"flash" wrote in message <it50bc$j6m$1@newscl01ah.mathworks.com>...
> "flash" wrote in message <it4vkt$hfr$1@newscl01ah.mathworks.com>...
> > Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
> >
> > I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
> >
> > Using the following i can produce the map but none of the data held in z is appearing???
> >
> > ...
> >
> > m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> > m_coast('patch',[1 .9 .7]);
> > m_tbase('contourf',[x:y:z];
> > m_grid('box','fancy','tickdir','in');
> >
> > ( x, y and z are all the same size)
> >
> > ANy help is greatly appreciated
>
> How do i associate the values held in x and y with the Long and Lat values of the grid?
>
> Any ideas??

If I take the m_map out of it

[Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
Grid = griddata(x, y, z, Lat, Long);
contourf(Lat, Long, Grid, 50);

I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?

Subject: Contour plot using m_map

From: TideMan

Date: 13 Jun, 2011 20:22:00

Message: 4 of 14

On Jun 14, 1:16 am, "flash " <phil...@hotmail.com> wrote:
> "flash" wrote in message <it50bc$j6...@newscl01ah.mathworks.com>...
> > "flash" wrote in message <it4vkt$hf...@newscl01ah.mathworks.com>...
> > > Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
>
> > > I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
>
> > > Using the following i can produce the map but none of the data held in z is appearing???
>
> > > ...
>
> > > m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> > > m_coast('patch',[1 .9 .7]);
> > > m_tbase('contourf',[x:y:z];
> > > m_grid('box','fancy','tickdir','in');
>
> > > ( x, y and z are all the same size)
>
> > > ANy help is greatly appreciated
>
> > How do i associate the values held in x and y with the Long and Lat values of the grid?
>
> > Any ideas??
>
> If I take the m_map out of it
>
> [Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
> Grid = griddata(x, y, z, Lat, Long);
> contourf(Lat, Long, Grid, 50);
>
> I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?

Use m_contourf, not m_tbase
m_contourf(Lat,Long,Grid,50)

Subject: Contour plot using m_map

From: flash

Date: 14 Jun, 2011 08:22:04

Message: 5 of 14

TideMan <mulgor@gmail.com> wrote in message <631e14ff-b605-4cc9-9321-505e5528e9a3@k15g2000pri.googlegroups.com>...
> On Jun 14, 1:16 am, "flash " <phil...@hotmail.com> wrote:
> > "flash" wrote in message <it50bc$j6...@newscl01ah.mathworks.com>...
> > > "flash" wrote in message <it4vkt$hf...@newscl01ah.mathworks.com>...
> > > > Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
> >
> > > > I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
> >
> > > > Using the following i can produce the map but none of the data held in z is appearing???
> >
> > > > ...
> >
> > > > m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> > > > m_coast('patch',[1 .9 .7]);
> > > > m_tbase('contourf',[x:y:z];
> > > > m_grid('box','fancy','tickdir','in');
> >
> > > > ( x, y and z are all the same size)
> >
> > > > ANy help is greatly appreciated
> >
> > > How do i associate the values held in x and y with the Long and Lat values of the grid?
> >
> > > Any ideas??
> >
> > If I take the m_map out of it
> >
> > [Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
> > Grid = griddata(x, y, z, Lat, Long);
> > contourf(Lat, Long, Grid, 50);
> >
> > I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?
>
> Use m_contourf, not m_tbase
> m_contourf(Lat,Long,Grid,50)

Thank you for your reply...

Using the below code it sort of works however i was trying to get the contour to fill the land on the map as opposed to just sitting in almost a diamond shape on top of it:

clc
clear
x = xlsread('MAP','Sheet1','C4:C12');
y = xlsread('MAP','Sheet1','D4:D12');
z = xlsread('MAP','Sheet1','E4:E12');


m_proj('lambert','long',[2 -6],'lat',[49.9 55.5]);
[lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
TempGrid = griddata(x, y, z, lat, long);
m_contour(lat, long, TempGrid, 20);
m_coast('line');
m_grid;
colormap(flipud(gray));

At the moment the size of the contour plor is governed by:

[lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));

I want it to be governed by the map itself so it colours in the map

Any ideas how m_map handles this, as in some of the examples (which i appreciate link to databases) the land is perfectly coloured through i believe the 'patch' command but i'm not able to get this to work either??

Subject: Contour plot using m_map

From: TideMan

Date: 14 Jun, 2011 10:45:23

Message: 6 of 14

On Jun 14, 8:22 pm, "flash " <phil...@hotmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <631e14ff-b605-4cc9-9321-505e5528e...@k15g2000pri.googlegroups.com>...
> > On Jun 14, 1:16 am, "flash " <phil...@hotmail.com> wrote:
> > > "flash" wrote in message <it50bc$j6...@newscl01ah.mathworks.com>...
> > > > "flash" wrote in message <it4vkt$hf...@newscl01ah.mathworks.com>...
> > > > > Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
>
> > > > > I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
>
> > > > > Using the following i can produce the map but none of the data held in z is appearing???
>
> > > > > ...
>
> > > > > m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> > > > > m_coast('patch',[1 .9 .7]);
> > > > > m_tbase('contourf',[x:y:z];
> > > > > m_grid('box','fancy','tickdir','in');
>
> > > > > ( x, y and z are all the same size)
>
> > > > > ANy help is greatly appreciated
>
> > > > How do i associate the values held in x and y with the Long and Lat values of the grid?
>
> > > > Any ideas??
>
> > > If I take the m_map out of it
>
> > > [Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
> > > Grid = griddata(x, y, z, Lat, Long);
> > > contourf(Lat, Long, Grid, 50);
>
> > > I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?
>
> > Use m_contourf, not m_tbase
> > m_contourf(Lat,Long,Grid,50)
>
> Thank you for your reply...
>
> Using the below code it sort of works however i was trying to get the contour to fill the land on the map as opposed to just sitting in almost a diamond shape on top of it:
>
> clc
> clear
> x = xlsread('MAP','Sheet1','C4:C12');
> y = xlsread('MAP','Sheet1','D4:D12');
> z = xlsread('MAP','Sheet1','E4:E12');
>
> m_proj('lambert','long',[2 -6],'lat',[49.9 55.5]);
> [lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
> TempGrid = griddata(x, y, z, lat, long);
> m_contour(lat, long, TempGrid, 20);
> m_coast('line');
> m_grid;
> colormap(flipud(gray));
>
> At the moment the size of the contour plor is governed by:
>
> [lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
>
> I want it to be governed by the map itself so it colours in the map
>
> Any ideas how m_map handles this, as in some of the examples (which i appreciate link to databases) the land is perfectly coloured through i believe the 'patch' command but i'm not able to get this to work either??

Yes, but you have specified
m_coast('line')
This specifies the coastline as a line.
Doh
Did you bother typing:
help m_coast
And after you typed it, did you bother reading what it said:
          M_COAST('line', (standard line option,...,...) ) draws the
coastline
          as a simple line.
          M_COAST('patch' ( ,standard patch options,...,...) ) draws
the
          coastline as a number of patches.

You have specify it as a patch, e.g.,
m_coast('patch',[0.808 1 0.808])
will make it a nice light green.

Subject: Contour plot using m_map

From: flash

Date: 14 Jun, 2011 12:31:04

Message: 7 of 14

TideMan <mulgor@gmail.com> wrote in message <030e94bb-e734-4bd6-86a2-b493b783deca@34g2000pru.googlegroups.com>...
> On Jun 14, 8:22 pm, "flash " <phil...@hotmail.com> wrote:
> > TideMan <mul...@gmail.com> wrote in message <631e14ff-b605-4cc9-9321-505e5528e...@k15g2000pri.googlegroups.com>...
> > > On Jun 14, 1:16 am, "flash " <phil...@hotmail.com> wrote:
> > > > "flash" wrote in message <it50bc$j6...@newscl01ah.mathworks.com>...
> > > > > "flash" wrote in message <it4vkt$hf...@newscl01ah.mathworks.com>...
> > > > > > Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
> >
> > > > > > I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
> >
> > > > > > Using the following i can produce the map but none of the data held in z is appearing???
> >
> > > > > > ...
> >
> > > > > > m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> > > > > > m_coast('patch',[1 .9 .7]);
> > > > > > m_tbase('contourf',[x:y:z];
> > > > > > m_grid('box','fancy','tickdir','in');
> >
> > > > > > ( x, y and z are all the same size)
> >
> > > > > > ANy help is greatly appreciated
> >
> > > > > How do i associate the values held in x and y with the Long and Lat values of the grid?
> >
> > > > > Any ideas??
> >
> > > > If I take the m_map out of it
> >
> > > > [Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
> > > > Grid = griddata(x, y, z, Lat, Long);
> > > > contourf(Lat, Long, Grid, 50);
> >
> > > > I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?
> >
> > > Use m_contourf, not m_tbase
> > > m_contourf(Lat,Long,Grid,50)
> >
> > Thank you for your reply...
> >
> > Using the below code it sort of works however i was trying to get the contour to fill the land on the map as opposed to just sitting in almost a diamond shape on top of it:
> >
> > clc
> > clear
> > x = xlsread('MAP','Sheet1','C4:C12');
> > y = xlsread('MAP','Sheet1','D4:D12');
> > z = xlsread('MAP','Sheet1','E4:E12');
> >
> > m_proj('lambert','long',[2 -6],'lat',[49.9 55.5]);
> > [lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
> > TempGrid = griddata(x, y, z, lat, long);
> > m_contour(lat, long, TempGrid, 20);
> > m_coast('line');
> > m_grid;
> > colormap(flipud(gray));
> >
> > At the moment the size of the contour plor is governed by:
> >
> > [lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
> >
> > I want it to be governed by the map itself so it colours in the map
> >
> > Any ideas how m_map handles this, as in some of the examples (which i appreciate link to databases) the land is perfectly coloured through i believe the 'patch' command but i'm not able to get this to work either??
>
> Yes, but you have specified
> m_coast('line')
> This specifies the coastline as a line.
> Doh
> Did you bother typing:
> help m_coast
> And after you typed it, did you bother reading what it said:
> M_COAST('line', (standard line option,...,...) ) draws the
> coastline
> as a simple line.
> M_COAST('patch' ( ,standard patch options,...,...) ) draws
> the
> coastline as a number of patches.
>
> You have specify it as a patch, e.g.,
> m_coast('patch',[0.808 1 0.808])
> will make it a nice light green.

Yes i appreciate that but even with the above code, the data which i am trying to contour is not appearing as a patch on the map, it sits as part of a separate grid on top of the map???

Subject: Contour plot using m_map

From: TideMan

Date: 14 Jun, 2011 19:46:56

Message: 8 of 14

On Jun 15, 12:31 am, "flash " <phil...@hotmail.com> wrote:
> TideMan <mul...@gmail.com> wrote in message <030e94bb-e734-4bd6-86a2-b493b783d...@34g2000pru.googlegroups.com>...
> > On Jun 14, 8:22 pm, "flash " <phil...@hotmail.com> wrote:
> > > TideMan <mul...@gmail.com> wrote in message <631e14ff-b605-4cc9-9321-505e5528e...@k15g2000pri.googlegroups.com>...
> > > > On Jun 14, 1:16 am, "flash " <phil...@hotmail.com> wrote:
> > > > > "flash" wrote in message <it50bc$j6...@newscl01ah.mathworks.com>...
> > > > > > "flash" wrote in message <it4vkt$hf...@newscl01ah.mathworks.com>...
> > > > > > > Hi there I am trying to produce a contour plot onto a map using longitude and latitude data...
>
> > > > > > > I have a 3 matrices x & y containing long and lat co-ordinates and 'z' a specific data value at those co-ordinates.
>
> > > > > > > Using the following i can produce the map but none of the data held in z is appearing???
>
> > > > > > > ...
>
> > > > > > > m_proj('lambert','long',[2 -6],'lat',[-49.9 56]);
> > > > > > > m_coast('patch',[1 .9 .7]);
> > > > > > > m_tbase('contourf',[x:y:z];
> > > > > > > m_grid('box','fancy','tickdir','in');
>
> > > > > > > ( x, y and z are all the same size)
>
> > > > > > > ANy help is greatly appreciated
>
> > > > > > How do i associate the values held in x and y with the Long and Lat values of the grid?
>
> > > > > > Any ideas??
>
> > > > > If I take the m_map out of it
>
> > > > > [Lat, Long] = meshgrid(linspace(min(x), max(x)), linspace(min(y), max(y)));
> > > > > Grid = griddata(x, y, z, Lat, Long);
> > > > > contourf(Lat, Long, Grid, 50);
>
> > > > > I get what I'm after I'm then just unsure how to get this to sit on top of the m_map stuff so that it appears on the map...?
>
> > > > Use m_contourf, not m_tbase
> > > > m_contourf(Lat,Long,Grid,50)
>
> > > Thank you for your reply...
>
> > > Using the below code it sort of works however i was trying to get the contour to fill the land on the map as opposed to just sitting in almost a diamond shape on top of it:
>
> > > clc
> > > clear
> > > x = xlsread('MAP','Sheet1','C4:C12');
> > > y = xlsread('MAP','Sheet1','D4:D12');
> > > z = xlsread('MAP','Sheet1','E4:E12');
>
> > > m_proj('lambert','long',[2 -6],'lat',[49.9 55.5]);
> > > [lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
> > > TempGrid = griddata(x, y, z, lat, long);
> > > m_contour(lat, long, TempGrid, 20);
> > > m_coast('line');
> > > m_grid;
> > > colormap(flipud(gray));
>
> > > At the moment the size of the contour plor is governed by:
>
> > > [lat, long] = meshgrid(linspace(min(x), max(x)),linspace(min(y), max(y)));
>
> > > I want it to be governed by the map itself so it colours in the map
>
> > > Any ideas how m_map handles this, as in some of the examples (which i appreciate link to databases) the land is perfectly coloured through i believe the 'patch' command but i'm not able to get this to work either??
>
> > Yes, but you have specified
> > m_coast('line')
> > This specifies the coastline as a line.
> > Doh
> > Did you bother typing:
> > help m_coast
> > And after you typed it, did you bother reading what it said:
> >           M_COAST('line', (standard line option,...,...) ) draws the
> > coastline
> >           as a simple line.
> >           M_COAST('patch' ( ,standard patch options,...,...) ) draws
> > the
> >           coastline as a number of patches.
>
> > You have specify it as a patch, e.g.,
> > m_coast('patch',[0.808 1 0.808])
> > will make it a nice light green.
>
> Yes i appreciate that but even with the above code, the data which i am trying to contour is not appearing as a patch on the map, it sits as part of a separate grid on top of the map???

Type:
help hold on

And once you've understood that, try plotting the coastline before
m_contour

Subject: Contour plot using m_map

From: phanidruva@gmail.com

Date: 20 Oct, 2013 10:16:51

Message: 9 of 14

Namastey ,

hello there..

I am new to use matlab..

here is my problem.. I am having data of monthly average of u_current v_current for particular location. like wise for three locations. all are in different excel sheets..

I want to plot them on a Indian base map..to know how the current pattern for monthly wise..

My data consists of three columns. 1st column is jun,jul,aug,....
2nd column is u_ current values.. 3rd column is v_current values...

I donno how to do... If you please provide me some code..It would be very helpful for my project..

Thank you in advance..

Subject: Contour plot using m_map

From: phanidruva@gmail.com

Date: 20 Oct, 2013 11:30:07

Message: 10 of 14

hey there...

In my matlab when i type m_proj or m_contour it is showing

??? Undefined function or method 'm_proj' for input arguments of type
'char'.
 
so what to do with that..

help me out ..

thanks in advance..

Subject: Contour plot using m_map

From: TideMan

Date: 20 Oct, 2013 20:05:30

Message: 11 of 14

On Monday, October 21, 2013 12:30:07 AM UTC+13, phani...@gmail.com wrote:
> hey there...
>
>
>
> In my matlab when i type m_proj or m_contour it is showing
>
>
>
> ??? Undefined function or method 'm_proj' for input arguments of type
>
> 'char'.
>
>
>
> so what to do with that..
>
>
>
> help me out ..
>
>
>
> thanks in advance..

It's an extra toolbox that you have to download and install.
Google m_map to find it.

Subject: Contour plot using m_map

From: phanidruva@gmail.com

Date: 21 Oct, 2013 06:23:41

Message: 12 of 14

thank you Tideman..

But how to draw vector plots for ocean currents at a particular location..
like I am having monthly average data of u-current and v_current at location.

now i want to plot current direction at that location for january..and save that image..
after that for february... so on.. help me out..

thanks in advance..

Subject: Contour plot using m_map

From: TideMan

Date: 21 Oct, 2013 09:03:57

Message: 13 of 14

On Monday, October 21, 2013 7:23:41 PM UTC+13, phani...@gmail.com wrote:
> thank you Tideman..
>
>
>
> But how to draw vector plots for ocean currents at a particular location..
>
> like I am having monthly average data of u-current and v_current at location.
>
>
>
> now i want to plot current direction at that location for january..and save that image..
>
> after that for february... so on.. help me out..
>
>
>
> thanks in advance..

m_demo
gives examples.
You'll see plots of currents there.

Then
help m_proj
help m_vec

You need to read the manual and have a go, then if you have trouble, show the code that is causing the problem.

Subject: Contour plot using m_map

From: phani

Date: 22 Oct, 2013 15:43:07

Message: 14 of 14

TideMan <mulgor@gmail.com> wrote in message <f8c948f7-8497-4260-a873-63359eb62669@googlegroups.com>...
> On Monday, October 21, 2013 7:23:41 PM UTC+13, phani...@gmail.com wrote:
> > thank you Tideman..
> >
> >
> >
> > But how to draw vector plots for ocean currents at a particular location..
> >
> > like I am having monthly average data of u-current and v_current at location.
> >
> >
> >
> > now i want to plot current direction at that location for january..and save that image..
> >
> > after that for february... so on.. help me out..
> >
> >
> >
> > thanks in advance..
>
> m_demo
> gives examples.
> You'll see plots of currents there.
>
> Then
> help m_proj
> help m_vec
>
> You need to read the manual and have a go, then if you have trouble, show the code that is causing the problem.


Thank you Tideman

I plotted ocean currents using m_proj and m_vec commands its very easy using mat-lab

thanks a lot for your help...

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