Creating Python Scripts in the Global Mapper App

The script processing tool in the Global Mapper Pro application allows for editing and executing scripts which can run on your workspace to help automate workflows. By default, it will accept Global Mapper scripts and workspaces (.gms and .gmw files) but can be easily extended to work with Python scripts as well. This can either be done by installing the Python libraries into the app with the Global Mapper installer, or by using a installed version of Python 3.9 on your system. See the sections below for full instructions on either of these methods.

Once the necessary Python files have been connected to your version of Global Mapper Pro, you can begin working with Python scripts by opening the Global Mapper app, clicking File, and then clicking either Run Script… to open an existing script file or Open Script Editor… to begin a new, blank script. You can also use ctrl+shift+O as a shortcut to Run Script… as well. If a .py file is loaded in, it will be automatically recognized as a Python script and ready to run. If you write a new script yourself in the editor, be sure to click Edit, then Language, and choose Python, or just save as a .py file so that Global Mapper can identify it as a Python script to provide syntax highlighting and run it correctly.

If you are a beginner at scripting with Python, you can review the Code Examples and Explanations section in this documentation to see some short sample scripts as a starting point.

../_images/script_editor.png

Setting up Python with the Global Mapper Installer

The simplest way to prepare Global Mapper for Python scripting is to install the necessary libraries using the Global Mapper installer; this can be done either during the first-time installation of the app or after the app has already been installed.

To get the Python Libraries during first-time installation of Global Mapper, proceed through the installer wizard until the “finish” window and, instead of completing the installation, click on Extra Downloads.

../_images/installer_extra_downloads.png

In the following screen, select Python Embeddable Libraries and then click Next >.

../_images/installer_py_libs.png

After a short load, the Python files will be ready and you can finish the installation. Global Mapper will now be ready to run scripts as soon as it is opened.


If you have already installed Global Mapper on your system, you can still use the same installer tool to install the Python libraries without needing to reset your copy of Global Mapper with a fresh install. Run the installer, and once the first window opens, choose the radio button for Modify Available Options, and then click Next >.

../_images/installer_modify.png

The installer will load for a few seconds, and then a window that says “Completing the InstallAware Wizard for Global Mapper” will open. From here, you can follow the same steps as shown in the screenshots above: click Extra Downloads, choose Python Embeddable Libraries in the next window, and click Next >.

The installer will load for a few more seconds, and then it will take you back to the previous screen. You can now click Finish to complete the modification and close the installer. Your copy of Global Mapper will now be able to run Python scripts.

Using an Existing Python Installation to Run Scripts in Global Mapper

If Python is already installed in your system, Global Mapper will be able to detect and use this version automatically so that you don’t have to install any extra libraries. As long as you have at least one copy of Python 3.9, you don’t need to take any further steps to enable Python script editing in Global Mapper. If you want to check whether you have a version of Python already installed, open a Command Prompt window and type “py -0” and press enter. You should see something like this:

C:\Users\yourname>py -0
Installed Pythons found by py Launcher for Windows
-3.9-64 *

As long as at least one version number with 3.9 is shown, your Global Mapper is ready to run Python scripts. If you have multiple versions of Python installed (for example, 3.9-64 and 3.9-32), Global Mapper will automatically choose the best one to use.

For more information on installing Python 3.9 on your computer, refer to the Python documentation on initial setup: https://docs.python.org/3/using/windows.html