Objective:
I have a GDB which contains X,Y, and an array channel. I would like to convert each element in the array
into single rows in the GDB. So each X,Y location would be repeated for the number of elements in the array.
From
To
Resolution:
Copy and paste the following text into a text editor and save as "Array2channel.gs" in your project directory.
Edit the appropriate lines to direct the script to your database and number of elements in the array.
Note: when you run the script, if there are problems an error message will state the line that is a problem. Open your script in a text editor to examine the line causing the error.
/-----------------------------------------------------------------------
/For a given an array channel, the VA2VV GX will create a single-element
/channel by copying all the array data into a single array.
/The last value in each array element will be followed by the first value in
/the next array element.
/The interactive on allows the user to select the array channel.
/If interavtive off, then the VA2VV.VA="Enter_Array_Channel" variable will be used
CURRENT Database,"C:\YOUR PATH AND DATABASENAME.gdb"
SETINI VA2VV.VA="Enter_Array_Channel"
SETINI VA2VV.VV="IP_elements"
interactive on
GX va2vv.gx
interactive off
/Use the MAKEFID GX to create a fiducial channel based on a specified reference
/channel. The reference channel is used to determine a start fiducial,
/fiducial increment, and number of elements to create.
CURRENT Database,"C:\YOUR PATH AND DATABASENAME.gdb"
SETINI MAKEFID.IN="X"
SETINI MAKEFID.OUT="Index_2"
SETINI MAKEFID.TYPE="FLOAT"
GX makefid.gx
/Use the LOADDBVU GX to loads a previously saved view to the
/currently active database editor.
/A .DBVIEW file is required for this to run creation of the "forsubset.dbview"
/is described in the help article "How to convert an array channel into multiple rows using a Geosoft script."
CURRENT Database,"C:\YOUR PATH AND DATABASENAME.gdb"
SETINI LOADDBVU.FILE=".\\forsubset.dbview"
GX loaddbvu.gx
/Use the DBSUBSET GX to create a new SUBSET database from the current database.
CURRENT Database,"C:\YOUR PATH AND DATABASENAME.gdb"
SETINI DBSUBSET.DIALOG="Yes"
SETINI DBSUBSET.COMPRESSION="1"
SETINI DBSUBSET.NAME=".\\IPTime_Index.gdb"
SETINI DBSUBSET.LINES="All"
SETINI DBSUBSET.CHANNELS="Displayed"
SETINI DBSUBSET.DUMMY="No masking"
SETINI DBSUBSET.MASK=""
SETINI DBSUBSET.COMPRESSION="0"
SETINI DBSUBSET.SAVE_AS="0"
GX dbsubset.gx
CURRENT Database,"C:\SEEQUENT\311699\IPTime_Index.gdb"
SETINI MAKEFID.IN="IP_elements"
SETINI MAKEFID.OUT="FIDUCIAL"
SETINI MAKEFID.TYPE="FLOAT"
GX makefid.gx
/MATHEXPRESSIONBUILDER is used to input channel math functions
CURRENT Database,"C:\SEEQUENT\311699\IPTime_Index.gdb"
/EDIT C0 = DIV(C1,*) where * is the number of windows in your array
SETINI MATHEXPRESSIONBUILDER.CHANNELINPUTBOX="C0 = DIV(C1,*);"
SETINI MATHEXPRESSIONBUILDER.CHANNELEXPRESSIONFILE=""
SETINI MATHEXPRESSIONBUILDER.CHANNELSTOREDID0="C1"
SETINI MATHEXPRESSIONBUILDER.CHANNELSTOREDVALUE0="FIDUCIAL"
SETINI MATHEXPRESSIONBUILDER.CHANNELSTOREDID1="C0"
SETINI MATHEXPRESSIONBUILDER.CHANNELSTOREDVALUE1="INDEX_2"
SETINI MATHEXPRESSIONBUILDER.CHANNELNUMSTORED="2"
SETINI MATHEXPRESSIONBUILDER.CHANNELTRIGUNITS="Degrees"
GX geogxnet.dll(Geosoft.GX.MathExpressionBuilder.MathExpressionBuilder;RunChannel)
/Use the LOOKUPDBCH GX to set the contents of a channel in one database based on a
/table lookup of values in a second database, using a reference channel.
CURRENT Database,"C:\SEEQUENT\311699\IPTime_Index.gdb"
SETINI LOOKUPDBCH.DB=".\\IPTime_Index.gdb"
CURRENT Database,"C:\YOUR PATH AND DATABASENAME.gdb"
SETINI LOOKUPDBCH.DB=".\\IPTime_Index.gdb"
CURRENT Database,"C:\SEEQUENT\311699\IPTime_Index.gdb"
SETINI LOOKUPDBCH.DB=".\\YOUR DATABASE NAME.gdb"
SETINI LOOKUPDBCH.REFCH="Index_2"
SETINI LOOKUPDBCH.DATACH="X"
SETINI LOOKUPDBCH.LOOKUP="0"
SETINI LOOKUPDBCH.DIST=""
GX lookupdbch.gx
SETINI LOOKUPDBCH.DATACH="y"
GX lookupdbch.gx
/-------------------------------------------------------------------
The following database view is needed to subset the data in the above script. Copy and pase the following text
into a text editor and save as forsubset.dbview in the same directory as the .gs file
/GEOSOFT LIST
/------------
"EDB_CELL_CHANNEL","IP_elements"
"EDB_PROF_BEGINLIST","*"
"EDB_PROF_SPLIT","0.86040609"
"EDB_PROF_SPLIT1","1"
"EDB_PROF_SPLIT2","0"
"EDB_PROF_SPLIT3","0"
"EDB_PROF_SPLIT4","0"
"EDB_PROF_SPLIT5","0"
"EDB_PROF_LINE","L1"
"EDB_PROF_ENDLIST","*"
"EDB_CELL_AUTORESCALE_X","1"
"EDB_CELL_VERTICAL_GRID_LINES","0"
"EDB_CELL_VERTICAL_GRID_LINES_INTERVAL","0"
To run the script
Open your Geosoft project.
Go to Project--- Scripting--- Run Script (or click the "Run Script" Icon in the Project Manager.)
Click the "..." next to the Script dialog field to navigate and select the .gs you just created.
Click "ok"
Notes:
Read any error message carefully. If the script does not run, the error will indicate the line in the text that has the problem. Open the .gs in a text editor to investigate.