Python is connected with several libraries providing many open-source and commercial (proprietary) functions for the analyses of geospatial data. This section introduces both, open-source and (briefly) the commercial arcpy library. The goal of this section is to provide an understanding of how geospatial data can be used and manipulated with Python code. The file manipulation involves logical and algebraic operations, and conversion from and to other geospatial file formats.
The descriptions of open source packages for geospatial data handling build on explanations from Michael Diener’s Python Geospatial Analysis Cookbook (open access under MIT license). Therefore, if you want to learn more details about any here information provided, take a look at this comprehensive e-book.
Another excellent source of inspiration with many open-sourced examples is pcjericks GitHub repository py-gdalogr-cookbook.
How to use PyQGIS (QGIS Python environment)
To enable working with QGIS commands in standalone Python scripts through from qgis.core import *, have a look at the PyQGIS section at the bottom of the QGIS tutorial in this eBook.