Show/Hide Toolbars

CatchmentSIM Help

 

CreateNewGrid ( Grid Name , Grid Type)

 

The CreateNewGrid procedure will create a new, blank raster grid and will add it to the CatchmentSIM project.  The grid can be of type DECIMAL, INTEGER or TEXT.

 

Parameter

Description

Accepted Values / Data Type

Grid Name

Name of the new grid. Note that grid names cannot contain any spaces (use underscores if spaces are required)

String

Grid Type

Indicates what type of data will be stored in the new grid (i.e., decimal/integer - numerical or text - string)

DECIMAL

INTEGER

TEXT

 

 

EXAMPLE

 

CreateNewGrid(&Var,DECIMAL)

 

 

AddGroupLayer (Group Name)

 

The AddGroupLayer procedure will create a new, empty group layer and will place this in the View Controller.

 

Parameter

Description

Accepted Values / Data Type

Group Name

Name of new group layer.  Group name must be inserted between double quotes (i.e., " ")

String

 

 

EXAMPLE

 

AddGroupLayer("Subcatchment Boundaries")

 

 

MoveLayertoGroupLayer( Layer Name , Group Name)

 

The MoveLayertoGroupLayer procedure will take an existing layer (vector or raster) and will move it to an existing group layer. Please note that standard CatchmentSIM generated vector and raster layers (e.g., DEM, subcatchment boundaries, longest flow paths etc) cannot be moved into group layers.

 

Parameter

Description

Accepted Values / Data Type

Layer Name

Full name of the raster or vector layer that is to be moved. Layer name must be inserted between double quotes (i.e., " ")

String

Group Name

Name of existing group layer into which the raster or vector layer will be placed.  Group name must be inserted between double quotes (i.e., " ")

String

 

EXAMPLE

 

MoveLayertoGroupLayer("220-SubCatchments.shp","Subcatchment Boundaries")

 

 

RunZonalStatistics ( Use Form , Zonal Grid , Statistics Grid , Ignore No Data )

 

The RunZonalStatistics procedure runs CatchmentSIM's Zonal Statistics algorithm. The algorithm can either be run in manual model (Use Form = True) where the user will be prompted to select the Zonal and Statistics Grids or in Auto mode (Use Form = False) where the script specifies the specific grids to be used in the analysis. More information can be found in the table below.

 

Parameter

Description

Accepted Values / Data Type

Use From

If TRUE, the Run Zonal Statistics Form will appear allowing the user to select the appropriate zonal and statistics grid manually.

If FALSE, then the zonal and statistics grid must be specified using the additional parameters outlined below.

TRUE or FALSE

Zonal Grid

Integer indicating the grid layer to be used as the Zonal Grid (For CatchmentSIM subcatchments use -1, for CatchmentSIM catchment use -2).

This parameter is irrelevant unless Use From is FALSE.

Integer

Statistics Grid

Integer indicating the grid layer to be used as the Statistics Grid.

This parameter is irrelevant unless Use From is FALSE.

Integer

Ignore No Data

If TRUE, all grid cells with "no data" values (i.e., grid cells with "nodata" or a "0" value) will be ignored in the zonal statistic calculations.

If FALSE, all grid cells will be considered in zonal statistics calculations irrespective of their values.

TRUE or FALSE

 

 

EXAMPLE

 

{Select Grid Related to Rainfall Depth}
SetupComboBox("Select rainfall grid","Rainfall Analysis")
 
LOOP(i|1|%GridLayers.NumberOfGridLayers|  
 AddComboBoxItem(%GridLayers.Grid[i].Name,False)
)
DisplayComboBox(&SelectedGrid)
 
{Convert grid name to id}
LOOP(i|1|%GridLayers.NumberOfGridLayers|
 IF(%GridLayers.Grid[i].Name|=|&SelectedGrid|AssignVariable(&GridIndex,[i]))
)
{As we want all rainfall information to be considered in zonal stats (even "0" values), we need to set "Ignore No Data" variable to FALSE}
RunZonalStatistics(FALSE,-1,&GridIndex,FALSE)
 
 
{After this point, the results can be obtained via the %ZonalStatistics variables}

 

 

RunCategorisedZonalStatistics ( Use Form, Layer Array )

 

The RunCategorisedZonalStatistics procedure runs CatchmentSIM's Categorised Zonal Statistics algorithm. The algorithm can either be run in manual model (Use Form = True) where the user will be prompted to select the relevant layers or in Auto mode (Use Form = False) where the script specifies the specific grids to be used in the analysis. More information can be found in the table below.

 

Parameter

Description

Accepted Values / Data Type

Use From

If TRUE, the Run Categorized Zonal Statistics Form will appear allowing the user to select the appropriate grid layers manually.

If FALSE, then the appropriate grid layers must be specified using the "Layer Array".

TRUE or FALSE

Layer Array

Array variable of integers indicating the grid layers to be used in the Categorised Zonal Statistics (For CatchmentSIM subcatchments use -1, for CatchmentSIM catchment use     -2).

This parameter is irrelevant unless Use From is FALSE.

Integer

 
EXAMPLE

 

{Select Grids using a form}
SetupCheckListBox("Select grids","Categorised Zonal Statistics")
 
SetArrayLength(&SelectedGrid,0)
 
LOOP(i|1|%GridLayers.NumberOfGridLayers|  
 AddCheckListBoxItem(%GridLayers.Grid[i].Name,False)
)
 
DisplayCheckListBox(&SelectedGrid)
 
{Convert to integers instead of names}
GetArrayLength(&LoopLength,&SelectedGrid)
LOOP(j|1|&LoopLength|
 LOOP(i|1|%GridLayers.NumberOfGridLayers|
   IF(&SelectedGrid[j]|=|%GridLayers.Grid[i].Name|AssignVariable(&SelectedGrid[j],[i]))
 )
)
 
RunCategorisedZonalStatistics(FALSE,&SelectedGrid)
 
{After this point, the results can be obtained via the %CatZonalStatistics variables}
 
{Write a file listing the Categorised Zonal Statistics Results}
SaveDialogBox(&PrintFile,"CSV File (*.csv)",".csv","")
StartPrintToFile(&PrintFile,ASCII,WINDOWS,OVERWRITE)
 
{Write Header}
LOOP(i|1|%CatZonalStatistics.NumberOfGridsUsed|
 TXT($34)TXT(%CatZonalStatistics.Cat[1].Grid[i].GridName)TXT($34)TXT(",")
)
TXT($34)TXT("Cell Count")TXT($34)
;
 
{Write Data}
LOOP(i|1|%CatZonalStatistics.NumberOfCategories|
 LOOP(j|1|%CatZonalStatistics.NumberOfGridsUsed|
   TXT($34)TXT(%CatZonalStatistics.Cat[i].Grid[j].GridValue)TXT($34)TXT(",")
 )
 TXT($34)TXT(%CatZonalStatistics.Cat[i].CellCount)TXT($34);
)
 
EndPrintToFile(&PrintFile)

 

 

InterpolateGridFromPoints ( Filepath / Grid_Name / Field / Algorithm / Query_Field / Query_Against )

 

The InterpolateGridFromPoints interpolates a new grid based on values in an external vector file using the same approach as the Interpolate Grid From Points form. The points can also be queried based on any single attribute in the file.  More information can be found in the table below.

 

 

Parameter

Description

Accepted Values / Data Type

Filepath

The file path to the vector file (mif, shp, 12da or CSV)

String

Grid_Name

The short name of the interpolated grid. Note this should not clash with any existing file or grid. Should not include spaces.

String

Field

The header of the attribute columns for the interpolation values. For example, “Elev”

String

Algorithm

A string that indicates the interpolation algorithm and parameters. Refer to http://gdal.org/gdal_grid.html for more details. Examples include:

invdist” – Inverse distance with default parameters.

average:radius1=100:radius2=100” – Moving average  with 100 m search radius (these parameters must be set for this algorithm).

nearest” – Nearest value algorithm with default parameters.

invdist: power=2.0:smoothing=1.0” – Inverse distance specifying power and smoothing, others default.

String

Query_Field

Fill in this field if you wish to apply a query to the points. For example, if you are used a CSV file with values for numerous dates, you may use a query like: “Date” = ”01/01/2000”. In this case, set this field to “Date”.

String

Query_Against

The value to query against. In the above example, set this to ”01/01/2000”

String

 
EXAMPLE

 

InterpolateGridFromPoints("C:\CatchmentSIM Projects\Working Files\rain_stations.csv","r_stations","Elev","invdist","","")