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:
How can I retrieve a lat lon position from a height contour map?

Subject: How can I retrieve a lat lon position from a height contour map?

From: elalexcs K

Date: 18 Jan, 2010 18:36:06

Message: 1 of 4

Hello

I am looking for a function that can retrieve an approximate Lat Lon position for a height contour. We are tracking eddies over the sea surface and we would like to know their approximate position over the surface to estimate their distance traveled.

Any clue would help
thanks for your time and attention

Subject: How can I retrieve a lat lon position from a height contour map?

From: TideMan

Date: 18 Jan, 2010 18:44:13

Message: 2 of 4

On Jan 19, 7:36 am, "elalexcs K" <elale...@gmail.com> wrote:
> Hello
>
> I am looking for a function that can retrieve an approximate Lat Lon  position for a height contour. We are tracking eddies over the sea surface and we would like to know their approximate position over the surface to estimate their distance traveled.
>
> Any clue would help
> thanks for your time and attention

How can anybody possibly help when you give us so little information?

Was the contour map drawn by Matlab's contour function or is it an
image?
Are the contours lines or shading?
What do you mean by "height contour"? Is it a depth contour? If not,
height of what?
etc
etc

Subject: How can I retrieve a lat lon position from a height contour map?

From: Rob Campbell

Date: 18 Jan, 2010 19:09:04

Message: 3 of 4

Your post is vague, but is this what you mean?

f=find(myContourData==contourValue);
[i,j] = ind2sub(size(myCountourData),f);

i and j are the row and column indecies of points in your matrix that had value "contourValue". Presumably you can convert i and j to lat. and long.

Subject: How can I retrieve a lat lon position from a height contour map?

From: Andrew Stevens

Date: 18 Jan, 2010 20:02:06

Message: 4 of 4

"Rob Campbell" <matlab@robertREMOVEcampbell.removethis.co.uk> wrote in message <hj2bkf$ss9$1@fred.mathworks.com>...
> Your post is vague, but is this what you mean?
>
> f=find(myContourData==contourValue);
> [i,j] = ind2sub(size(myCountourData),f);
>
> i and j are the row and column indecies of points in your matrix that had value "contourValue". Presumably you can convert i and j to lat. and long.

Assuming you are trying to get the coordinates of a contour plot made in Matlab, check out the following ex:

%example data
[X,Y,Z]=peaks(50);

figure
[cs,h]=contour(X,Y,Z);
hold on

%extract the contour data
len=size(cs,2);
pos=1;
numc=1;
cdata=struct('contour',[],...
    'numel',[],...
    'x',[],...
    'y',[]);
while pos<len
    cdata(numc).contour=cs(1,pos);
    cdata(numc).numel=cs(2,pos);
    cdata(numc).x=cs(1,pos+1:pos+cdata(numc).numel);
    cdata(numc).y=cs(2,pos+1:pos+cdata(numc).numel);
    pos=pos+cdata(numc).numel+1;
    numc=numc+1;
end

%extract the location of the -2 contour
ind=([cdata(:).contour]==-2);
x=arrayfun(@(x)(x.x),cdata(ind),'uni',0);
y=arrayfun(@(x)(x.y),cdata(ind),'uni',0);
    
%plot the selected contour
cellfun(@(x,y)(plot(x,y,'k-','linewidth',3)),x,y)


-Andrew

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