Python

Python is one of the most popular programming languages in the world. Its low learning curve paired with a massive ecosystem has made it a powerful tool for geospatial computing. GIS software like QGIS and ArcGIS, provide the ability to extend their functionality through Python, while many programming libraries that have been created to efficiently perform geospatial computing tasks have been either written in Python, released as Python packages, and/or include application programming interfaces (APIs) that coherently communicate with Python code.

If you need recommendations for installing and getting started with Python on your local machine, see Getting Started with Conda, Virtual Environments, and Python.

The following resources will provide general introductions to Python and its applications within data science, so any of them can be useful for learning the basics of Python.

Geospatial Books

Extending GIS Software

Geospatial Libraries/Packages

A relatively comprehensive list of packages can be found in the Python section of Awesome Geospatial.

Many of the packages included in that list provide powerful, easy-to-use functionalities around GDAL. If you need to write code that directly interacts with GDAL, Python bindings are provided, which can be explored through the GDAL documentation.

You may also find some other helpful packages listed in Python for Data Science - Geodata.

Interactive Visualizations and Dashboards

Dashboard libraries enable you to create interactive visualizations from either Python code or Jupyter Notebooks, which can be hosted on sparsely-resourced servers and shared as web applications. You can find information about some of the most popular libraries at PyViz - Dashboarding tools.

Resources for developing interactive maps via a dashboarding library are listed below:

Alternatively, libraries like Voici can similarly convert notebooks to interactive applications, but rather than running the Python code on a server, Voici shifts computation off of the server and into a user’s web browser using WebAssembly (WASM) and a static webpage. This makes hosting the application virtually free via services like GitHub Pages while also making it easier to manage and preserve. The crucial downside to note is that user’s with poor internet connections and/or limited hardware will struggle to run the applications, especially those that include large datasets and long, resource-intensive computations.

Code Quality Tools

Each of the tools listed below can be easily integrated with most development environments and set up to run automatically. When working with Jupyter Notebooks, we strongly encourage you to install nbqa alongside these tools in order to ensure code quality within your notebooks.

Formatting

Sometimes writing code can get a bit messy. Formatters, like black, can automatically reformat your code to make it cleaner and easier to read while following a set of standards and best practices.

Linting

Using a static analysis tool, or linter, is a common best practice among programmers that helps in identifying and fixings mistakes when writing code by ensuring that you follow the correct syntax and a guiding set of best practices.

Type Checking

While Python is inherently a dynamically typed language, meaning you the programmer don’t have to worry about the data types of each variable, static types can be helpful for reducing bugs when writing complex scripts or programs. Mypy enables programmers to annotate types into their code and returns a helpful error when those types aren’t explicitly followed.

Testing Framework

Similar to type checking, unit testing can be a helpful tool when writing large and complex scripts or programs. Testing frameworks, like pytest, which is included in Python’s standard library, enable you to define tests that can run over your functions and ensure they are following expected behavior in a range of practical scenarios.