Getting Started with the GlobalMapper Python SDK¶
The Global Mapper Python SDK is a module which extends Python to include many of the functionalities from the Global Mapper application. This is a useful tool if you want to automate a series of Global Mapper operations or perform quick GM functions without depending on the interface.
In order to use the Global Mapper SDK, your system needs to have a version of Python 3.9 installed; you can check if you have any versions of Python installed by typing “py -0” into a command prompt. For more information on installing Python 3.9, refer to Python’s own documentation on setup: https://docs.python.org/3/using/windows.html
There are two ways to link your copy of Python to the Global Mapper SDK files. If you want to get started quickly with the SDK, open a Command Prompt window and enter this command:
set PYTHONPATH=C:\GlobalMapper\GlobalMapperSDK_v23\bin64
Note
If you have moved your installation of the GM SDK from the default location, make sure to change the filepath in the command to match its new location. If you are using a different version of Global Mapper than 23.0, change the name of the directory accordingly. If you wish to use the 32-bit version instead, replace bin64 with just bin.
This will allow command line Python to import globalmapper so that you can begin using the SDK from the Command Prompt window. However, this will only last as long as the window; once you close the Command Prompt window, you’ll need to set the path again when you next open another Command Prompt window. Nonetheless, this command is a helpful shortcut if you want to get started quickly and simply, or if you anticipate leaving your Command Prompt window open for a while.
Setting the New Environment Variable¶
The second, more permanent way to connect the Global Mapper module to Python involves creating an environment variable on your system to set a path to the GM SDK files. This method only needs to be done once, and then Python will always be able to import globalmapper regardless of where it is run.
First, open a System Properties window by going to Settings -> System -> About -> Advanced system settings or by typing “environment variables” into the Windows search box and clicking the result called “Edit the system environment variables”.
From the System Properties window, go to the Advanced tab and click on the Environment Variables button.
Next, in the Environment Variables window, choose the lower New… button, underneath the System Variables box. This will open a window to enter the name and location for a new environment variable and path. For Variable name, type PYTHONPATH, and for Variable value type C:\GlobalMapper\GlobalMapperSDK_v23\bin64, as shown below. If you have moved the Global Mapper SDK directory from the default location, enter its new filepath instead. For other versions of the GM SDK, replace v23 with the version number you have installed. Note that the Python module is not present in GM SDK versions <23.0. If you are using a 32-bit system, replace bin64 with just bin.
After typing the name and value, press OK to complete the new variable window and then OK again to close the Environment Variables window and the System Properties window. Now Python has the path to your Global Mapper SDK files and will be able to access the module for import in any context in which Python can run. Simply call import globalmapper in any Python instance to begin programming with the GM SDK.