| |

How to Install GeoPandas and Check GeoPandas Version

GeoPandas is a high-level Python package for reading, writing, analyzing, and manipulating vector (points, lines, and polygons) geographic data. As the name ‘GeoPandas’ implies, it brings pandas data frame functionality to geographic data so that you interact with the data much as you would an attribute table in ArcMap or QGIS or a spreadsheet in Excel. GeoPandas also has built-in plotting capabilities, which make it easy to create and display maps and visualizations.

Installing GeoPandas is quite simple, but there are a couple of nuances you’ll need to watch out for, especially if you’re using Windows. I’ll demonstrate how to install GeoPandas with conda (Anaconda/Miniconda) and discuss what you’ll need to do to install GeoPandas with pip.

Installing with Anaconda/Miniconda

It is recommended to install GeoPandas with Anaconda or Miniconda with the conda package manager. Using conda for installation will automatically download and install all of GeoPandas’ dependencies. If you’re using Windows, this is basically the only way to install GeoPandas (at least presently) without compiling and installing fiona from scratch.

GeoPandas is available for installation from both the default package channel and the conda-forge package channel. Below, I demonstrate how to install from both channels, and why you might want to use conda-forge.

I’ve found that the GeoPandas installation with conda can take several minutes, a fair amount longer than most packages. So, if your installation is taking longer than you expect, don’t worry too much, it happens to me too.

Installing from the default channel

Installing from the default channel is simple and doesn’t require any extra arguments. Just use the command below.

conda install geopandas

Installing from the conda-forge channel

The main reason you may want to install GeoPandas from the conda-forge channel is that there are some packages that are not available on the default channel. Installing all packages from the same channel ensures maximum compatibility between packages. It’s okay to install packages from different channels, and it usually works out fine, but it does increase the risk of compatibility issues.

Many GIS-related packages that you might want to use with GeoPandas (like gdal and rasterio) are not available on the conda default channel (presently). Personally, I always use the conda-forge channel because I do so much work with geospatial data.

Use the command below to install GeoPandas from the conda-forge channel. The two commands are identical. The first uses the long form (--channel to specify the channel argument and the second uses the short form (-c).

conda install --channel conda-forge geopandas
conda install -c conda-forge geopandas

Installing with PIP

You can also install GeoPandas with pip, if you absolutely must, and are not using Windows. To install with pip you’ll need to manually install all of the GeoPandas dependencies. I recommend following the instructions in the GeoPandas documentation to do this.

The reason you can’t use pip to install GeoPandas on Windows is that fiona, which is a GeoPandas dependency, is very difficult to install on Windows. In short, compiled fiona wheels, which make it simple to install Python packages are not created for Windows so you’ll have to compile fiona from scratch. This is not a simple task. For Windows users, save yourself the trouble and used conda.

If you really have to install GeoPandas on Windows with pip, try this . . .

There may be some instances where you have to install GeoPandas with PIP on Windows. For those instances, I’ve found this installation works somewhat consistently (it may not work for your specific circumstance) without needing to install fiona. We’re going to install pyogrio as a replacement to fiona (as suggested in the GeoPandas documentation).

With a little luck, these commands will also work for you. I recommend creating a blank environment to start from to limit dependency and compatability issues.

pip install pyogrio
pip install pyproj
pip install rtree
pip install shapely
pip install geopandas

Check your GeoPandas version

After you install GeoPandas you may find you need to reference the version number you are using to ensure compatibility with other packages, to check which features are available in your version, or to determine if you need to update to a new version. Checking the GeoPandas version is easy and can be done with both conda and pip.

With conda.

conda list geopandas

Output from conda.

# packages in environment at C:\Users\Konrad\miniconda3\envs\test:
#
# Name                    Version                   Build  Channel
geopandas                 0.12.2             pyhd8ed1ab_0    conda-forge
geopandas-base            0.12.2             pyha770c72_0    conda-forge

With pip.

pip show geopandas

Output from pip.

Name: geopandas
Version: 0.12.2
Summary: Geographic pandas extensions
Home-page: http://geopandas.org
Author: GeoPandas contributors
Author-email: kjordahl@alum.mit.edu
License: BSD
Location: c:\users\konrad\miniconda3\envs\win_gpd\lib\site-packages
Requires: fiona, packaging, pandas, pyproj, shapely
Required-by:

Conclusion

Many of you have probably figured out these installation nuances from the GeoPandas documentation, but if you’re newer to Pandas and/or Python you may have trouble understanding documentation lingo (I know I did). That’s why I’ve written this post, to hopefully address installation issues you may be facing that you didn’t know how to address. I hope it helps!

Similar Posts