Using the GDAL library to load and query rasters

Now that you have gdal installed, import it using:

from osgeo import gdal

GDAL 2 is the most recent version. If you have an older version of gdal installed, you may need to import it using the following code:

import gdal

If this is the case, you may want to look into upgrading your version of gdal. Once you have gdal imported, you can open a raster image. First, let's get an image from the web. The Earth Data Analysis Center at the University of New Mexico maintains the Resource Geographic Information System (RGIS). In it, you will find New Mexico GIS data. Browse to http://rgis.unm.edu/ and from the Get Data link, Select Shaded Relief, General, and New Mexico. Then, download the Color Shaded ...

Get Mastering Geospatial Analysis with Python 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.