Show diameter distribution
Distribution charts are often useful in data analysis. Field-Map provides with the functionality for such purpose:
procedure ShowDistributionChart( TableOrLayer :TObjectWrapper;
const AttributeName_ :string;
const NullAsZero_ :Boolean;
const ClassDef_ :variant;
const Xlabel_,ChartLabel_,Options_ :string);
Data come from project layer or table (e.g. query result).
NullAsZero parameter specifies whether missing values are assumed to be zero or skipped from the calculations.
ClassDef parameter specifies classes of a distribution. It can be represented by a single value which represents width of the class. In this case all classes are of the same width. The other option is specification of the range of class boundaries, e.g. VarArrayOf([5,10,20,30,40,50]).
Parameter OPTIONS can be used for various adjustments of distribution or chart:
Option |
Description |
Values |
Default |
BOUNDS |
left or right closed intervals used for classification |
LEFTSIDE or RIGHTSIDE LEFTSIDE = TRUNC( (X) / (ClassWidth) )+1 i.e. <5,10),<10,20),.. RIGHTSIDE = trunc( (X-1) / (ClassWidth) )+1 i.e. (5,10>,(10,20>,.. |
RIGHTSIDE |
FULLRANGE |
show full range of classes specified by class boundaries or optimize range of classes for particular data |
YES or NO |
NO |
Multiple options can be passed to the function, individual options are separated by semicolon.
EXAMPLE:
BOUNDS=LEFTSIDE;FULLRANGE=NO
In the example project there are several sample plots with diameter at breast height for all trees. The aim is to present diameter distribution in user defined classes for all trees together and for individual tree species.
var tbSpecies,tbTrees :TTableWrapper;
begin
tbSpecies :=
Project.GetQueryResult(format( 'SELECT DISTINCT '
+'Trees.Species,qspecies.Value1 AS Species_lkp '
+'FROM Trees '
+'INNER JOIN qspecies '
+'ON Trees.Species = qspecies.ID '
+'ORDER BY Trees.Species',
[Plots.ValueAsinteger['ID']]));
try
//overall distribution
tbTrees :=
Project.GetQueryResult( 'SELECT CAST(DBH_mm AS FLOAT)/10 AS DBH_cm '
+'FROM Trees '
+'WHERE Trees.IntactSnag=11 '
+'AND Trees.AliveDead=11 '
+'AND Trees.IndShtCop=10');
try
ShowDistributionChart( tbTrees,
'DBH_cm',
false,
VarArrayOf([5,10,20,30,40,50,60,70,80,90,100,110]),
'DBH,cm',
'All species',
'BOUNDS=LEFTSIDE;FULLRANGE=NO');
finally
tbTrees.Free;
end;
//diameter distribution by species
tbSpecies.First;
while not tbSpecies.EOF do begin
tbTrees :=
Project.GetQueryResult(format('SELECT CAST(DBH_mm AS FLOAT)/10 AS DBH_cm '
+'FROM Trees '
+'WHERE Species=%d '
+'AND Trees.IntactSnag=11 '
+'AND Trees.AliveDead=11 '
+'AND Trees.IndShtCop=10',
[tbSpecies.ValueAsInteger['Species']]));
try
ShowDistributionChart( tbTrees,
'DBH_cm',
false,
VarArrayOf([5,10,20,30,40,50,60,70,80,90,100,110]),
'DBH,cm',
format('Species: %s',[tbSpecies['Species_lkp']]),
'BOUNDS=LEFTSIDE;FULLRANGE=NO');
finally
tbTrees.Free;
end;
tbSpecies.Next;
end;
finally
tbSpecies.Free;
end;
end.
See also:
Working with Field-Map data - scan and locate table records; Handling exceptions; Working with Field-Map data - using SQL queries; Parameterize regression models; Show diameter distribution; Grouping species; Working with Log window; Management of screen interface
© 2024 IFER-Monitoring and Mapping Solutions