Skip to main content

How to Download GDAL with Anaconda

Sharon Fitzpatrick

Sharon Fitzpatrick

Coast Train Developer

Tutorial: How to Download GDAL with Anaconda.

Installing GDAL with Anaconda

Install Anaconda

  1. First, you need to have Anaconda installed on your computer, download it here: https://www.anaconda.com/products/individual#Downloads

  2. Second, once you have Anaconda successfully installed open it.

Create a virtual environment

We need to create a virtual environment within Anaconda to hold our installation of GDAL. An environment in Anaconda is like a separate space for your code to live in where it will not interfere with other code you have.

  1. Run the command: conda create --name pygdal

    This will create an environment called "pygal" where we will later be installing gdal here. Quick Note: You can name your environment whatever you please, but in this tutorial and the following tutorials I will be using "pygdal" as the environment name.

  2. Anaconda will prompt you asking if you want to proceed[y/n] : Type y

  3. Lastly, run the command: conda activate pygdal

    This command will activate your new environment named "pygdal".

Install GDAL

  1. Inside your virtual environment named "pygdal" run the command:

conda install conda-forge gdal

This will install the gdal package in the environment,"pygdal" you just created.

  1. A list of files will pop up and Anaconda will prompt you asking if you want to proceed[y/n] : Type y

    It will take a few minutes to finish downloading. When it is close to finishing you will see the following:

    "

    Preparing transaction: done

    Verifying transaction: done

    Executing transaction: done

    "

Verify Your Installation of GDAL

  1. Run the command: conda list gdal

    This command verifies we have gdal installed. As you can see in the screenshot below I have version 3.3.1 .

  2. Run the command: python

    This opens a python shell we can type commands into.

Image

  1. Run the command: from osgeo import gdal

    When we downloaded the gdal package we downloaded the entire osgeo library, which includes gdal. You should see output similar to the image below. If you get errors like "import GDAL not found" this means your installation failed.

  2. Run the command: exit()

    This exits the python shell.

  3. Congrats!๐ŸŽ‰ You successfully downloaded GDAL with Anaconda!

  1. Anaconda's official Download Page for GDAL: https://anaconda.org/conda-forge/gdal
  2. Official GDAL Documentation: https://gdal.org/download.html