September 7, 2021

Python in Global Mapper Pro

Written by: Mackenzie Mills


With the release of Global Mapper v23, Blue Marble introduces Global Mapper Pro, a version containing additional advanced GIS tools, including expanded scripting capabilities with Python. Python is a widely-used interpreted programming language commonly utilized for development and scripting in many sciences and GIS programs. 

Global Mapper Pro will allow users to embed or use an existing installation of Python version 3.9 to create and run scripts written in Python. These scripts can be run through the Global Mapper user interface or outside of the program through the command line or a python environment.

To better write and manage scripts in Global Mapper the Script Editor dialog is another new addition to Global Mapper Pro. This dialog allows the user to choose to work in Global Mapper Script or Python, and then create and even run scripts through the dialog. To help in writing and reading scripts, the script text will be colored to easily differentiate between comments, commands, and parameters.

The new Script Editor, accessed from the File menu, allows users to create, edit, and run Python and Global Mapper scripts within the program user interface.

This new Python integration in Global Mapper opens the program to Python developers and allows the functions of Global Mapper to be integrated into scripts run within the Global Mapper interface or a Python environment. Through a Python script, the Global Mapper libraries are imported, and many commands from the Global Mapper program can be utilized. Some of the commonly used Global Mapper actions available through a Python script are:

  • Loading Layers
  • Display / Drawing
  • Coordinates and Measurement
  • Exporting Layers
  • Image and Elevation Query
  • Vector Query
  • Vector Editing
  • Vector Styling
  • Lidar Query and Filtering
  • 3D View (open, close, position camera, control layers, and extent) 
  • Terrain Analysis
  • Spatial Operations
  • Running an existing Global Mapper Script
  • And many, many more

In addition to directly interacting with data through Global Mapper, the integration with Python allows users to access other tools and commands from installed 3rd party Python libraries and write new custom tools to be used in Global Mapper. Overall this greatly expands the options users have when working with Global Mapper tools. 

Using a Python script an entire workflow can be automated in Global Mapper. Run through the interface in this case, the generated results are loaded to be explored further in Global Mapper when analysis is complete. 

This script starts with a prompt to select a point cloud file to load, and then works through a grid creation and watershed analysis to identify streams and catchment areas. This analysis, common for environmental planning and water management teams, is now totally contained within a Python script that can be repeatedly run for different datasets.

The data created from running this script in Global Mapper are a terrain grid and grouped watershed layers describing the streams and catchment areas for this region.

Below, another example of a simple Python script created and run in the Script Editor dialog imports libraries other than Global Mapper, and uses these additional tools to generate information and graphics that can be displayed alongside the Global Mapper program. In this case, the open-source PIL and Matplotlib libraries are used to read data from a raster file also loaded into Global Mapper,  and create a histogram showing the distribution of the RGB color values present in the selected raster image.

By importing and using an external tool in a python script, a histogram image can be generated and displayed for a raster image file that is selected and loaded into Global Mapper.

Get ready to use python with Global Mapper by installing python v3.9 and signing up for updates about the release of Global Mapper Pro slated for mid-September.  

If you enjoyed this blog, you may also find these other resources useful:

Ask the Experts: Support for Python Scripting

Exploring a Python Script in Global Mapper Pro

Companies using Blue Marble’s geospatial technology