Learning Objectives

  • Understand the role and significance of package managers in the context of software development and geospatial data science.

  • Create and activate a new conda environment.

  • Use conda and conda to install geospatial packages from the conda-forge channel.

  • Recognize key geospatial packages


Geospatial Environment Installation Guide#

In the world of software development, package managers have become a fundamental tool for simplifying the installation of software packages and their dependencies. They automate the process of installing, upgrading, configuring, and removing software packages in a consistent manner. In the field of geospatial data science, where several packages need to be installed, package managers ensure a smooth and efficient setup of your environment.

Follow the instructions to install conda here

Creating and Activating a New Environment#

Each project or workflow may require different versions of packages or even different packages altogether. To manage these variations, it is best practice to create isolated environments for each project. This prevents conflicts between package versions and ensures that your projects remain reproducible.

You can create a new environment in conda using the following command:

conda create --name myenv

Replace myenv with the name of your environment.

To activate this environment, use:

conda activate myenv

Now, any package you install will be installed in this environment, keeping it isolated from other environments.

Installing Geospatial Packages#

Before we install the packages, we need to add conda-forge to your channels:

conda config --add channels conda-forge
conda config --set channel_priority strict

Then, we can install geowombat and geowombat-ml using conda or conda. For conda:

conda install geowombat geowombat-ml

Following this, we need to install the following packages: pyproj, contextily, earthpy, census, geoplot, osmnx, pykrige, and us. We will start with the packages available through conda-forge:

conda install pyproj geopandas       

Finally install those packages that aren’t available through conda-forge:

pip install census contextily earthpy geoplot osmnx us pykrige

Now you have all the packages installed and ready to be used in your new environment!

Verifying the Installation#

Next we need to activate the environment and verify that the packages are installed correctly.

First activate the environment you created earlier:

conda activate myenv

The enter a pythone session by typing:

python

You should now see >>> in your terminal, indicating that you are in a Python interpreter session.

To verify that the packages are installed correctly, you can run the following commands in a Python interpreter:

import geowombat
import geowombat_ml
import pyproj
import geopandas
import contextily
import earthpy
import census

Now you can exit the Python interpreter by typing:

exit()

Note

If you encounter any errors during the import, it means that the package is not installed correctly. You can try reinstalling the package or checking for any dependencies that may be missing.