Global Mapper v25.0

Altering elevation values for an ASCII export

Greetings, I am trying to export an arc ascii grid but prevent values outside of a predetermined min and max from being passed on. Here is what I have so far:

GLOBAL_MAPPER_SCRIPT VERSION=1.00


//import ASCII data and ignore all values outside of the -5 to -65 range
IMPORT FILENAME="TG_004_BKSC_Caris.asc" \
TYPE=ARCASCIIGRID INC_ELEV_COORDS=YES MIN_ELEV='-5' MAX_ELEV='-65'

 // export the file as imported - ignoring the values less than -5 and greater than -65
EXPORT_ELEVATION FILENAME="C:\Users\surve\Desktop\Mike Reed\GM_scripts/Caris_test.asc" \
TYPE=ARCASCIIGRID GEN_PRJ_FILE=YES


The exported ASCII file includes all data and does not ignore the values outside of the bounds I have tried to set

Answers

  • bmg_bob
    bmg_bob Global Mapper Programmer
    Answer ✓
    Hello,

    The easiest way to get a good IMPORT command is to have Global Mapper do it for you as follows:
    1. Load your data into Global Mapper
    2. Use the Elevation Options | Alter Elevation Values tab to set the Maximum Valid Elevation and Minimum Valid Elevation
    3. Save a workspace
    4. Open the workspace file in a text editor such as Notepad.
    5. Copy the IMPORT command (you will likely also want the DEFINE_PROJ ... END_DEFINE_PROJ lines also so you will have the correct projection information) to your script file.
    Cheers,
    Bob
  • Many thanks!

  • Bob,
       I am trying to alter this code to import altitude data from a SSS and need to remove the points that are out of spec for the job I am on, only keeping the data between 5 and 7.5m. Below are the Script Processing results from GM

    Importing ASCII file PATH\SSS_M694_50m_XY-Alt.csv...
    WARNING: Unknown COORD_ORDER value, X_FIRST will be used.
    Exporting elevation data to file <SSS_M694_50m_XY-Alt_in-spec>...
    ERROR: Elevation data must be loaded for EXPORT_ELEVATION command.

    Here is my code;
    GLOBAL_MAPPER_SCRIPT VERSION=1.00

    //define the directory and filename needed for conversion
    DEFINE_VAR NAME="DIR_TO_LOAD" PROMPT="DIR" ABORT_ON_CANCEL=NO
    DEFINE_VAR NAME="FILE_TO_LOAD" PROMPT="FILE" VALUE="%DIR_TO_LOAD%" \
    ABORT_ON_CANCEL=YES

    //define the parameters for exporting a file to a user selectable directory
    DEFINE_VAR NAME="DIR_TO_EXPORT" PROMPT="DIR" VALUE="1" 

    //define newly exported file name
    DEFINE_VAR NAME="FILE_TO_EXPORT" PROMPT= VALUE="_in-spec" \
    ABORT_ON_CANCEL=YES

    //import CSV file and ignore all values outside of the 5.0 to 7.5 range 
    IMPORT_ASCII FILENAME="%FILE_TO_LOAD%" TYPE="POINT_ONLY" \
    INC_ELEV_COORDS="YES" SKIP_ROWS="1" \
    ELEV_UNITS="METERS" MIN_ELEV="5.000000" MAX_ELEV="7.5000000"

    DEFINE_PROJ PROJ_NAME="UTM_ZONE19_WGS84"
    Projection     UTM
    Datum          WGS84
    Zunits         NO
    Units          METERS
    Zone           19
    Xshift         0.000000
    Yshift         0.000000
    Parameters
    END_DEFINE_PROJ

    // export the file as imported - ignoring the values less than 5 and greater than 7.5
    EXPORT_ELEVATION FILENAME="%FILE_TO_EXPORT%" \
    TYPE=FIRST_LOADED

    I have banging my head against the wall for a couple days. Any help you could provide would be greatly appreciated! 
          Mike
  • bmg_bob
    bmg_bob Global Mapper Programmer
    edited October 2019
    Hello Mike,

    It sounds like you want to import a CSV file, including only points with elevation between 5.0 and 7.5 meters, then export the imported data to another CSV file. 

    To do this, you need to use EXPORT_VECTOR, not EXPORT_ELEVATION. Your export command will need to be similar to this:
    EXPORT_VECTOR FILENAME="%FILE_TO_EXPORT%" \
       TYPE=CSV EXPORT_ELEV=YES
    This is a basic command for exporting a CSV file with elevations. There are more parameters available, so look at the documentation for EXPORT_VECTOR to see if there are any more that are specific to your situation.

    Cheers,
    Bob
  • Bob,
      Thanks for your explanation. There is still one issue and that is the way the import is written the filter is not working. None of the elevation values lower than 5 and greater than 7.5 are being filtered out. Thoughts?
       Cheers,
               Mike
  • Hi Bob,
      I have successfully written the script for vector data importing, which does not allow me to filter out the <5, 7.5< values during import and written a script for elevation data but it changes the values by gridding the data. Is there a way to write this for vector data and filter the inputs so I can prevent having to manually filter these readings?
      Thanks again,
              Mike 
  • bmg_bob
    bmg_bob Global Mapper Programmer
    Hi Mike,

    Another option is to delete the features that are outside the range you desire. You can do this using the EDIT_VECTOR script command. In your case, the command should look like this (assumes elevation values are in an attribute called "ELEV"):
    EDIT_VECTOR COMPARE_STR="ELEV<5.0" COMPARE_STR="ELEV>7.5" COMPARE_OP="ANY" \
          DELETE_FEATURES="YES"
    This command will delete the features with elevations less than 5 and greater than 7.5.  You can then perform your export.  

    Cheers,
    Bob
  • Hi Bob,

       I followed your suggestion above and was able to get that string to work BUT I dont want to delete the points I am filtering. I tried the MOVE_TO_NEW_LAYER command but it is not removing the outliers from the imported file, instead it just moves them to the bottom of the file that I am exporting. Maybe I am employing the string incorrectly?

    EDIT_VECTOR FILENAME="%FILE_TO_LOAD%" COMPARE_STR="ELEVATION<5"  \ MOVE_TO_NEW_LAYER="YES" NEW_LAYER_NAME="-below-spec"
    EXPORT_VECTOR FILENAME="%FILE_TO_EXPORT%-below-spec.csv" EXPORT_LAYER="-below-spec" \  TYPE="CSV" DELETE_FEATURES="YES"

    Thanks again for helping me out with this!

       Cheers,
             Mike

        

  • bmg_bob
    bmg_bob Global Mapper Programmer
    Hello Mike,

    Something is not right in the processing for EDIT_VECTOR -- when Global Mapper copies the points that meet the condition in the COMPARE_STR, it also creates a line from those points. I will take a look at that to see what is happening. I think the commands below should move the points to a new layer and export them. Using SHAPE_TYPE on the EXPORT_VECTOR will make Global Mapper ignore the extraneous line feature that it created in the new layer.

    EDIT_VECTOR FILENAME="%FILE_TO_LOAD%" COMPARE_STR="ELEVATION<5" COMPARE_NUM=YES \
                MOVE_TO_NEW_LAYER="YES" NEW_LAYER_NAME="-below-spec"
    
    EXPORT_VECTOR FILENAME="%FILE_TO_EXPORT%-below-spec.csv" EXPORT_LAYER="-below-spec" \ TYPE="CSV" SHAPE_TYPE="POINTS" \
                  COORD_ORDER="Y_FIRST" EXPORT_ATTRS=NO
    Cheers,
    Bob