It has been historically fairly hard to install
GDAL along with all its C dependencies and make it play nicely with existing Python libraries leaving alone having multiple environments with multiple versions.
I have blogged a year ago on how to set up a nice open-source GIS sandbox using Anaconda. Nowadays, it got even easier. When installing Anaconda 4, an application called Anaconda Navigator will be installed. From the web site linked:
Anaconda Navigator is a desktop graphical user interface (GUI) that is included in Anaconda® and allows you to launch applications and easily manage conda packages, environments and channels without using command-line commands. You can configure Navigator to search for packages on Anaconda Cloud or in a local Anaconda Repository. It is available for Windows, macOS and Linux.
Using the Anaconda Navigator, you can install
GDAL without even starting a terminal!
Here are the steps you need to follow:
- Download and install Anaconda 4.x, 64-bit, Python 2.7, Windows version.
- Make sure to install Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package. If you don’t do that, you may get weird errors when trying to import
gdalin your Python code.
gdal2.1.0 using the Navigator application.
- Optionally, add a system environment for specifying the
gdalfolder in your Anaconda installation folder –
GDAL_DATA = C:\Users\dev\Anaconda2\Library\share\gdal– if you would need to work with spatial references, for instance, use
pyprojto re-project coordinates.
- Start a Python command prompt and run
import ogr. If both have been successfully imported, you are good to go!
It is very easy to manage your packages using Navigator. Make sure to add some other Conda channels such as
conda-forge because you won’t be able to find all geospatial packages you might need in the default channel. Thereafter, you can easily add
pyprojand other geospatial Python packages such as