Page 1 of 1

How to draw the contour?

Posted: Sun Jul 29, 2007 7:25 am
by 9339728
HI
I have three arrays---Long, Lati, and Temperatuer.
I want to contouer on the Temperatuer.

I have done these code:

ContourSeries: TContourSeries;
.
.
.

With ContourSeries do
begin
Clear;
for i:=0 to 50 do
AddXYZ( Long,Temp ,Lati, '', clTeeColor);
end;


It doesn't work, anything wrong?
Please help me.

Posted: Sun Jul 29, 2007 7:36 am
by 9047589
If you create ContourSeries in your code manually you need something like this

Code: Select all

ContourSeries.ParentChart:=YourChart;

Do you use Chart Editor at all or maybe you do not have TChart component on your form?

Posted: Sun Jul 29, 2007 2:58 pm
by 9339728
I don't create the ContourSeries manually.
I find Teechart Demo use the two loop to add these data.
Why?[/quote]

Posted: Sun Jul 29, 2007 3:03 pm
by Marjan
For contour series you need 2d regular or irregular grid data. This is why you need two y=y(x,z) variables i.e. two for loops to populate the series. In case your data is not arranged as grid data, you'll first have to create grid data and then pass it to series using:

Code: Select all

for i := 0 to NumCellsGridX -1 do
  for j := 0 to NumCellsGridZ-1 do
   ContourSeries1.AddXYZ(i,y[i,j],j);
where i,j are data x,z grid indexes (in your case long, latt) and y[i,j] is data you're trying to plot (in your case temperature).

Posted: Sun Jul 29, 2007 4:13 pm
by 9047589
Hi, zheng!
In your case it seems you try to plot isotherms in geographical coordinates, therefore your Lat and Long array have to produce some grid. Isn't so?
I advice you to use Chart Editor in run-time with EditChart procedure and explore your series in run-time.

Posted: Mon Jul 30, 2007 4:05 am
by 9339728
Marjan wrote:For contour series you need 2d regular or irregular grid data. This is why you need two y=y(x,z) variables i.e. two for loops to populate the series. In case your data is not arranged as grid data, you'll first have to create grid data and then pass it to series using:

Code: Select all

for i := 0 to NumCellsGridX -1 do
  for j := 0 to NumCellsGridZ-1 do
   ContourSeries1.AddXYZ(i,y[i,j],j);
where i,j are data x,z grid indexes (in your case long, latt) and y[i,j] is data you're trying to plot (in your case temperature).
Thanks for your reply,In my case I only have one temperature data at one long and one lati.But In your program, I should get all temperature data at same long and different lati.I am not sure I make it clear.I wll give one table, that will be more clear.

Now I have three datas,Table 1
Long 100 102 103 104 105 106
Lati 94 96 98 91 90 84
Temp 23 25 26 20 29 21

You require datas, Table 2
Long 100 100 100 100 100 100 102 102 102 102 102 102 103 103 103 103 103 103...
Lati 94 96 98 91 90 84 94 96 98 91 90 84 94 96 98 91 90 84...
Temp 23 X X X X X 25 X X X X X 26 X X X X X...
these X datas I miss, How to get them?

Posted: Mon Jul 30, 2007 4:14 am
by 9339728
Hi,Alexander
Thanks for your reply.
I really will plot isotherms in geographical coordinates.
9047589 wrote:your Lat and Long array have to produce some grid. Isn't so?
How to produce the grid by Lat and Long?

Posted: Mon Jul 30, 2007 10:25 am
by 9047589
Well, you have produce 3D array. Better to have regular grid, i.e. without missing data, but it's not mandatory. It seems you have data only for one latitude - it's not enough for grid.
One example for you:
X Y Z
90 24.919 100
92 24.9392 100
94 24.9594 100
96 24.9796 100
98 24.9998 100
90 24.9372 102
92 24.9578 102
94 24.9784 102
96 24.999 102
98 25.0196 102
90 24.9554 104
92 24.9764 104
94 24.9974 104
96 25.0184 104
98 25.0394 104
90 24.9736 106
92 24.995 106
94 25.0164 106
96 25.0378 106
98 25.0592 106
90 24.9918 108
92 25.0136 108
94 25.0354 108
96 25.0572 108
98 25.079 108

Posted: Mon Jul 30, 2007 2:32 pm
by Marjan
9339728 wrote: Thanks for your reply,In my case I only have one temperature data at one long and one lati.But In your program, I should get all temperature data at same long and different lati.I am not sure I make it clear.I wll give one table, that will be more clear.

Now I have three datas,Table 1
Long 100 102 103 104 105 106
Lati 94 96 98 91 90 84
Temp 23 25 26 20 29 21

You require datas, Table 2
Long 100 100 100 100 100 100 102 102 102 102 102 102 103 103 103 103 103 103...
Lati 94 96 98 91 90 84 94 96 98 91 90 84 94 96 98 91 90 84...
Temp 23 X X X X X 25 X X X X X 26 X X X X X...
these X datas I miss, How to get them?
For contour series having a grid data is mandatory. For missing grid points you can generate data points by using simple (linear should do the trick) interpolation. I think TeeChart demo has an example of this: check the Surface Gridding node. It moreless does exactly what you need - creates 2d grid array from arbitrary y=y(x,z) data points.