Thursday, March 12, 2026

[017] Global Mapper - Elevation Layer 01

In the last post, I shared a script related to Python, but there were some layer-related functions I hadn't mentioned yet. While we're on the subject, I'd like to take a look at some frequently used features.

Global Mapper categorizes layer types into five main groups: Elevation (Terrain), Image (Raster), Point, Line, and Area (Polygon). The sub-items visible in the Layer menu change depending on the type of layer selected.

There are other types of layers, but I don't think many Global Mapper users will need to go that deep, so I won't be covering them here.

Let's start with the Elevation Layer.

One important thing to keep in mind is that Elevation Layers can be visually changed to represent slope or aspect simply by changing the Shader.

Global Mapper toolbar showing the Shader drop-down menu with options like Atlas, Slope, and Magma Shaders

Therefore, the functions we are about to discuss can be used consistently even if the shader is changed. You can download and open the sample .gmp file below to follow along.

Attachment: Layer_Management.zip (This is a safe proprietary data file for Global Mapper.)



Looking at the layers registered in the Control Center, you'll notice that the icon to the left of the layer name changes based on the elements the layer contains (Terrain, Raster, Point, Line, or Area).

Control Center window showing different icons for Elevation, Image, Point, Line, and Area layers


If you select a layer and right-click, a context menu appears. At the very bottom, you will see the Layer item. The sub-items under this menu vary depending on the layer type.

Right-click context menu in Control Center highlighting the "Layer" sub-menu at the bottom


Since we are only dealing with Elevation Layers today, let's look at the context menu specific to them.

List of sub-menu items under the Elevation Layer context menu


Brief Overview of Items:

  1. Create Workspace File from Selected Layer(s)...: Saves the selected layer as a Workspace file (.gmw).
  2. EXPORT - Export Layer(s) to New File...: Exports the selected layer to a new file format.
  3. MAP CATALOG - Add Selected Layer(s) to Map Catalog...: Adds the layer to a Map Catalog (useful for massive, national-scale datasets).
  4. BBOX/COVERAGES - Create Layer Coverage Box/Polygon Area Features: Generates a bounding box that encompasses all elements in the layer.
  5. Create Point Cloud from Elevation Layer: Converts elevation data into a Point Cloud.
  6. Create Area Features from Equal Values...: Creates polygons based on identical elevation values.
  7. Vectorize Raster: Converts data into vectors (lines or polygons) based on threshold values.
  8. Create Mesh Features from Terrain...: Generates mesh features based on terrain data (a preliminary step for creating TIN models).
  9. Find Extreme (Min/Max) Elevation Values...: Searches for the minimum and maximum elevation values within the layer.
  10. Link External Metadata File: Connects the layer with external metadata (XML, TXT, etc.).
  11. Save List of Layers to Text File...: Saves the current project's layer list as a text file.
  12. Set Background Color for Layer in Control Center: Sets a custom background color for the layer entry in the Control Center.

Items 1, 2, 3, 10, 11, and 12 are fairly self-explanatory, so let's explore the remaining functions. BBOX/COVERAGES is a common feature used across all layer types, not just Elevation. It creates a rectangular or polygonal border that contains every element in the selected layer.



Select Layers" dialog box where the user selects which layer to generate a BBOX for

When you select BBOX, a window appears asking you to select the layers. Select "Elevation" and click OK. Then, it asks whether you want a rectangular bounding area or a polygonal coverage area.

A terrain map showing a newly created rectangular red border around the elevation data]


Choosing "Yes" creates the smallest possible rectangle containing all elements. "No" creates a polygon that fits the actual shape of the data more closely. In the example, a new layer called Elevation (Bounds) is created.

Selecting the Point layer in the "Select Layers" dialog to create a polygonal coverage


Next, let's try creating a polygon around a Point layer using the "No" (Polygonal) option. A Concave Hull Options window will appear, allowing you to set the "Smoothing" factor. Higher smoothing hides imperfections, while lower values cling more tightly to the data boundary.

"Concave Hull Options" dialog box with a smoothing factor slider set to 100

Map showing a black polygonal line connecting six points over the elevation layer


Creating a Point Cloud

Now, let's look at Create Point Cloud from Elevation Layer. This function converts DEM (Digital Elevation Model) data into individual points, each containing an elevation value.

"Export Bounds" dialog box for determining the area where points will be generated


Personally, I wish there were a function to adjust the density of the generated points, but that option isn't available here. Once you click OK, an Elevation Points layer is created. In my test, it generated 44,290 features.

Zoomed-in view of the point cloud showing individual points

 If you turn off the DEM layer and zoom in, you can see the individual points. By using the Feature Info Tool (Alt+P) and clicking on a point, you can verify its specific attributes, including its precise elevation.
"Feature Information" window showing the elevation value of 98.86m for a specific LIDAR point

That's all for today...

[016] Global Mapper - Python Integration: Saving Vectors as Images

Today, I am posting a piece I wrote a while ago and had been putting off, after some refinement. I ask for your understanding; it has been difficult to concentrate on writing lately.


The reason I created this script was because I saw a close junior of mine manually zooming in and out of hundreds of parcels in CAD, capturing each one for a report. I thought he might not survive long if he kept working like that. I made this to solve the problem for him the next time he faced a similar task.

Main map view showing a satellite image background with bright green parcel vector outlines


As shown in the image above, you can divide the cadastral map by parcel into separate layers and then perform the following operations. (Global Mapper users will likely find this basic.)

I will cover how to separate the layers in a future post.

I originally planned to introduce integration with external languages after the lectures had progressed a bit more, but for now, just take a look at it to see that this kind of functionality is possible.

How to Use

  1. The satellite image layer (raster layer) at the bottom must be at the very top of the layer list. Turn off all other raster layers.
  2. Each parcel must be separated into its own layer. The layer description should be in English.
  3. Turn off all vector layers related to the parcels.
  4. Go to the File menu -> Open Script Editor, paste the code below, and save it with an appropriate name.
  5. Project folders and paths must all be in English.
  6. You can change the image save path on line 35.
  7. The image aspect ratio can be adjusted on line 9. It is currently set to 16:9.
  8. The horizontal pixel width is set on line 70. The vertical pixels are automatically determined to maintain the 16:9 ratio.
  9. Click the Run Script button to execute.
  10. Once you click Run Script, JPG images will be created in the specified path.

#/usr/bin/env python 
# coding=utf8 
import globalmapper as gm 
import os 

zoom_out_factor = 1.5
aspect_ratio = 16/9 

layers_are_loaded = gm.GetLoadedLayerList() 

if not layers_are_loaded: 
    print("No layers are currently open, so nothing was exported.") 
else: 
    arr_ptr, arr_size = layers_are_loaded 
    all_layers = gm.GM_LayerHandle_array_frompointer(arr_ptr) 
    raster_layers = [] 
    vector_layers = [] 
    
    for layer in gm.carray_to_list(all_layers, arr_size): 
        layer_info = gm.GetLayerInfo(layer) 
        if layer_info.mHasVectorData:
            vector_layers.append(layer) 
        elif layer_info.mHasRasterData: 
            raster_layers.append(layer) 
            
    if len(vector_layers) == 0:
        print("No vector layers were found, so nothing was exported.") 
    elif len(raster_layers) == 0:
        print("No raster layers were found to use as background.") 
    else: 
        # Set your export path here
        output_directory = os.path.expanduser("F:\\2024-08-26_export\\result\\") 
        print("Exporting files to {}".format(output_directory)) 
        
        gm.SetLayerEnabled(raster_layers[0], True) 
        
        for layer in vector_layers: 
            layer_info = gm.GetLayerInfo(layer) 
            try: 
                # Character encoding handling
                if layer_info.mCodePage == 949: 
                    layer_name = layer_info.mDescription.encode('raw_unicode_escape').decode('cp949') 
                elif layer_info.mCodePage == 0: 
                    layer_name = layer_info.mDescription.encode("latin1").decode("cp1252") 
                else: 
                    layer_name = layer_info.mDescription 
            except UnicodeDecodeError: 
                layer_name = layer_info.mDescription 
                
            name_wo_ext = layer_name[:layer_name.index(".")] if "." in layer_name else layer_name 
            name_wo_ext = name_wo_ext.replace(" ", "_") 
            name_wo_ext = "".join(c for c in name_wo_ext if c.isalnum() or c in "_-") 
            
            # Calculating bounding box and aspect ratio
            width_meters = layer_info.mGlobalRect.mMaxX - layer_info.mGlobalRect.mMinX 
            height_meters = layer_info.mGlobalRect.mMaxY - layer_info.mGlobalRect.mMinY 
            dim_ratio = width_meters / height_meters 
            
            center_x = (layer_info.mGlobalRect.mMaxX + layer_info.mGlobalRect.mMinX) / 2 
            center_y = (layer_info.mGlobalRect.mMaxY + layer_info.mGlobalRect.mMinY) / 2 
            
            if dim_ratio > aspect_ratio:
                new_width = width_meters * zoom_out_factor
                new_height = new_width / aspect_ratio
            else:
                new_height = height_meters * zoom_out_factor
                new_width = new_height * aspect_ratio
                
            new_min_x = center_x - new_width / 2 
            new_max_x = center_x + new_width / 2 
            new_min_y = center_y - new_height / 2 
            new_max_y = center_y + new_height / 2 
            
            export_rect = gm.GM_Rectangle_t(new_min_x, new_min_y, new_max_x, new_max_y) 
            
            gm.SetLayerEnabled(layer, True) 
            output_filename = os.path.join(output_directory, "{}.jpg".format(name_wo_ext)) 
            
            HD_WIDTH = 800 
            HD_HEIGHT = int(HD_WIDTH / aspect_ratio) 
            
            error_code = gm.ExportRaster(output_filename, gm.GM_Export_JPG, 0x0, export_rect, HD_WIDTH, HD_HEIGHT, gm.GM_ExportFlags_AddAlpha) 
            
            if error_code == gm.GM_Error_None: 
                print("Exported {} to {}".format(layer_name, output_filename)) 
            else: 
                print("Error exporting {}: {}".format(layer_name, gm.strerror(error_code))) 
                
            gm.SetLayerEnabled(layer, False) 

        gm.SetLayerEnabled(raster_layers[0], False)


I tinkered with lines 47–54 while trying to handle character conversion, but eventually left it as is. It works fine for English, so you can use it without issues. I was going to fix it but felt a bit too lazy.

I tested it with 500 parcels, and the export finished in less than 20 seconds. It’s incredibly satisfying.

Windows Explorer view showing a grid of exported parcel images with satellite backgrounds

As a side note, when using Python scripts in Global Mapper, you should handle everything in English. The path where the workspace is saved, the workspace name itself, and even the comments should ideally be in English for best compatibility.

That's all for today...

Wednesday, March 11, 2026

012] Global Mapper - Terrain Information Lines: Calculate Elevation/Slope Stats

Today, we will learn how to extract terrain information using Line features.

To follow along, please open the data file we used in the previous session.

Global Mapper screen showing the terrain, boundary, and road line from the previous session


1. Extracting Terrain Information for a Line

The process is identical to the one we used for polygons. We will use the same tool to analyze the terrain along our "Road" feature.

  1. Select the Road line using the Digitizer Tool.

  2. Right-click and select Analysis/Measurement -> Calculate Elevation/Slope Stats for Selected Feature(s)....

Right-click menu on the line feature selecting Calculate Elevation/Slope Stats


  1. A dialog will appear asking if you'd like to create new point features at the minimum and maximum elevations. Choose your preference (Yes to add points, No to just calculate).

Point creation confirmation dialog for min/max elevation points

If you select "Yes," points will be generated on your map showing the exact locations of the highest and lowest elevations along that line.

Main screen showing the road with blue and yellow triangle markers at min/max spots


2. Understanding Line-Specific Statistics

The Feature Information window will now display the results. While similar to the polygon results, there are several key items specific to line features.

Feature Information window showing comprehensive statistics for the road line


Key Statistics Explained for Lines:

  1. MAX_UP_SLOPE_DEG/PCT: The steepest incline (uphill) encountered along the path.

  2. MAX_DOWN_SLOPE_DEG/PCT: The steepest decline (downhill) encountered along the path.

  3. ELEV_GAIN_M/FT: The total cumulative elevation gain (sum of all uphill segments).

  4. ELEV_LOSS_M/FT: The total cumulative elevation loss (sum of all downhill segments).

  5. LENGTH_3D: The actual 3D distance of the line, taking the terrain's rises and falls into account.

Note on Direction:

In Global Mapper, lines have a direction. The Start point is marked in Green, and the End point is marked in Red when selected. "Up" and "Down" are relative to moving from the green point to the red point.

In this example, the ELEV_GAIN is 26.91m and the ELEV_LOSS is 16.94m. This means that while traveling from the start to the end, you climbed a total of 26.91m and descended 16.94m. Consequently, the end point is approximately 10m higher than the start.


3. Review: Using Path Profile

Let's visualize this data using the Path Profile tool we covered previously.

  1. With the line selected, right-click and select Analysis/Measurement -> PATH PROFILE - Generate Path Profile Along Line(s)....

Right-click menu selecting Path Profile


A cross-section of the terrain along the line will appear. The yellow dots at the bottom represent the vertices (corners) of the line.

Initial Path Profile window showing the terrain cross-section


The default view might show a lot of empty space below the terrain. Let's adjust the settings to focus on the relevant elevation.

  1. Go to Path Setup -> Path Profile Settings....

Path Profile menu selecting Settings


  1. In the General Settings tab:

    • Elevation Range: Check Clamp Bottom Displayed Elevation to and enter 75 (meters).

    • Guidelines: Check Draw Reference Line at and enter 90 (meters).

    • Click OK.

Path Profile Settings dialog with custom elevation and reference line values



Now, the unnecessary bottom space is removed, and a clear reference line is added at 90m.

Final Path Profile view with optimized elevation range and reference line


This analysis is incredibly useful for evaluating hiking trails, bicycle paths, or planned road routes. If you have multiple potential paths from point A to point B, comparing the total elevation gain and loss will tell you which route is the easiest or most challenging.

That’s all for today!