How to grid a .gdb channel in python.

I can write a python script to create a geosoft grid using the surfer API however can some generous person point to or give an example how to grid from a python script using the geosoft gxapi or gxpy? I don't understand why this basic step is not in the tutorial.

Comments

  • Hello Justin,

    I am not familiar with Python, but probably you may find a way to further translate a Geosoft script (gs file).
    My suggestion is to play with Script->Record Script (for example, recording test_gridding.gs) on a simple case, and then inspect the output gs file with a simple text editor. That would outline the logic of the process, what parameters you may want to set, like which database, channel, cellsize, output grid filename and type, gridding parameters, etc.

    Then you can edit this gs according to your specific preferences needs. Of course you can create such script programmatically (maybe with an Excel VBA macro or Python, and why not with Surfer scripting).

    The example below was created to exemplify the output I get from recording a script of "Grid and Image"->"Gridding-> "Direct Gridding..."

    Best regards,
    Dumitru

    test_gridding.gs content:

    /-------------------------------------------------------------------------
    / LOG OPENED : Tue May 18 06:42:35 2021
    /-------------------------------------------------------------------------
    CURRENT        CURRENT        Database,"d:\test_gridding\mag_data.gdb"
    SETINI         DIRECT_GRIDDING.DUMMY_ZEROS="1"
    SETINI         DIRECT_GRIDDING.CELL_SIZE="200"
    SETINI         DIRECT_GRIDDING.GRID="D:\\test\\test_dirgrd.grd(GRD)"
    SETINI         DIRECT_GRIDDING.CHANNEL="TMI"
    SETINI         DIRECT_GRIDDING.GRID_VALUE="2"
    SETINI         DIRECT_GRIDDING.MASK_CHANNEL=""
    GX             geogxnet.dll(Geosoft.GX.GridUtils.DirectGridding;Run)
    /-------------------------------------------------------------------------
    / LOG CLOSED : Tue May 18 06:43:48 2021
    /-------------------------------------------------------------------------


  • Thanks, Ill get familiar with the geosoft scripting and see where it leads.