GDAL

GDAL is the dominant geospatial library for raster data. Its raster capability is so significant that it is a part of virtually every geospatial toolkit in any language, and Python is no exception to this. To see the basics of how GDAL works in Python, download the following sample raster satellite image as a ZIP file and unzip it: https://github.com/GeospatialPython/Learn/raw/master/SatImage.zip. Let's open this image and see how many bands it has and how many pixels are present along each axis:

>>> from osgeo import gdal
>>> raster = gdal.Open("SatImage.tif")
>>> raster.RasterCount
3
>>> raster.RasterXSize
2592
>>> raster.RasterYSize
2693

So, we see that the following image has three bands, 2,592 columns of pixels, and 2,693 rows of pixels ...

Get Learning Geospatial Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.