Download 2014 User Manual
Transcript
Ag Data Mapping Solution - ADMS User Manual
202
P & K continued — Introducing - Select Case
Using Select Case is a way of re-directing
which path the script will use when it runs.
Dim P2O5 As Single
Dim K2O As Single
Dim MakeMap As Output
A simple example of using Select Case is
shown below with the Infield function.
Dim OlsenPST As Single = Rasters("P_OLSEN").Value
Dim ExpYield As Single = Rasters("2005 Corn Yield").Value
Dim KST As Single = Rasters("K_UNSPEC").Value
If you remember the InField function returns
a TRUE if the current cell is in the field, and a
FALSE if it isn‘t.
MakeMap = Output.P
If InField Then
Select Case MakeMap
Case Output.P
Select Case InField
Case True
‗Do this if I am in the field
Case False
‗Do this if I am not
End Select
ExpYield
'Check To See If it Is Less Than 20 ppm
If OlsenPST < 20 Then
P2O5 = (0.7 - (.044 * OlsenPST)) *
Else
End If
'Send the Value to the Map
Return P2O5
An example to the right demonstrates using
an Enumeration of the map to build in a
Select Case statement.
Case Output.K
'Check To See If it Is Less Than 175 ppm
If KST < 175 Then
K2O = (1.166 - (.0073 * KST)) * ExpYield
Else
‗It was over 175 ppm so apply 0
K2O = 0
End If
In this case, it will determine which output
map will be created.
It is a very powerful Tool that allows for
compound tests like below. This example has
nothing to do with Map Math but demonstrates a way to Divide by Ranges
'Send the Value to the Map
Return K2O
Dim Number as Integer =8
Select Case Number
Case 1 To 5
Return 3
Case 6 to 10
Return 8
Case 11 ,12
Return 11
Case 13 To 15
Return 15
Case Is > 20
Return 20
Case Else
Return 15
End Select
P2O5 = 0
End Select
Else
End If
‗Wasn‘t in the Map Return a Null Value
Return NullVal
‗Outside of the Main Function these 3 lines need to be Added.
‗This makes for the selection of P or K at the MakeMap variable.
Private Enum Output
P
K
End Enum
GK Technology, Inc. - 204 Fifth Street East, Halstad, MN - 855-458-3244 - www.gktechinc.com