geoconda is a simple repository of information for setting up a conda environment for analysis in a Windows/Mac environment.
Future versions will potentially include scripts that automatically create the conda environment.
Last Updated: March 4, 2020
To-Do:
- Mac, Linux compatability
- Automate conda environment setup
- Create miniconda compatability with setup
This guide requires that Anaconda is installed and conda is update to date (conda update conda command).
- Miniconda - A minimal version of Anaconda that "includes only conda, Python, the packages they depend on, and a small number of other useful packages, including pip, zlib and a few others"
- Anaconda - Full distribution of Anaconda including conda as well as several libraries
Helpful commands for troubleshooting include the following:
Get list of all conda environments:
conda env list
Get a list of packages in an environment:
conda list -n myenv
See if a package has been installed in an environment:
conda list -n myenv mypackage
See activate environment configuration:
conda config --show
See activate environment channels:
conda config --show channels
Remove an environment:
conda remove --name myenv --all
Note: manual installation is done via the anaconda prompt terminal that comes with Anaconda distributions Creating a new environment is done with the command:
conda create --name myenv
However, is it valuable to also specify the python version you are intending on using (for example, if a package you are using is only on certain python versions):
conda create --name myenv python=3.6
You can also create environments with specific packages (and specify versions), although it is easy enough to add these later:
conda create --name myenv scipy=0.15.0 numpy pandas
It is strongly recommended to install all programs at the same time to an environment to avoid dependency conflicts. Using a environment.yml file is usually the most ideal for avoiding dependency issues.
There are two different sections of packages to go over: generally useful packages (config, file management, general analytics, etc.) and the geospatial packages.
Here is a list of generally useful packages:
- SciPy Pack - includes scientific computing packages (numpy, pandas, scikit-learn) as well as many other ecosystem components (ipython, dask, additional scipy libraries)
- IPKernel - to enable usage of Jupyter notebooks with your environment
- matplotlib - plotting library that also allows spatial plotting
- xarray - multidimensional arrays, particularly useful for dealing with netCDF files and other spatial array data. optional dependencies can be definitely worth installing (dask, etc.)
- pandas - if not already installed (included in several other packages as dependencies)
Here is a list of packages that are particularly useful for geospatial analytics. Several are redundant to install as they can be dependencies of other packages listed:
- PySal - Python Spatial Analysis Library to perform spatial data analytics
- GDAL - Geospatial Data Abstraction Library package for Python, will require GDAL Windows Binaries to be installed
- PyProj - interface to PROJ
- geopandas - extends pandas functionality to geometric type data
- Fiona - for handling OGR spatial data
- Shapely - (included in cartopy)
- Cartopy - geospatial data processing for plotting
- netCDF4 - for handling netCDF data (climate data, etc.)
- rasterio - for handling raster data (GeoTIFF, etc.)
- pyshp - for writing to ESRI format spatial files
- geojson - for handling GeoJSON data
- Pillow - python Imaging Library fork for Python 3. Very valuable for image processing.
- Descartes - can be helpful if you plan to plot geometry in matplotlib
- seaborn - data visualization library that can be used for additional plotting options
Note: some packages (cartopy, etc.) recommend that you install using conda-forge as a channel. This is an optional method but be aware specifying conda-forge as a channel to install from can create endless solving loops upon installing packages. This guide uses conda-forge as recommended.
After selecting the packages desired from the above (and any additional packages), installing packages can be done as follows:
- Optionally enable conda-forge for packages that recommend it:
conda config --add channels conda-forge conda config --set channel_priority strict
- Install packages (recommended to do all at once to avoid dependency issues):
conda install --channel conda-forge scipy ipykernel xarray matplotlib seaborn cartopy Pillow pysal pyproj gdal shapely descartes pyshp geopandas rasterio fiona netCDF4
Below are some more advanced methods that can be used.
YML files can be used to export/import environment configurations. This is extremely helpful when trying to quickly set up/replicate an environment that will work consistently.
To export your active environment yml, navigate in (a non-conda) terminal to a directory you would like the file to be placed:
conda env export --name myenv > environment_myenv.yml
To create an environment from a yml file:
conda env create -f environment_myenv.yml
To enable the usage of this environment as a kernel in Jupyter, run the following Conda prompt command:
ipython kernel install --name myenv
Then you should be able to run Jupyter and select the environment as needed:
conda create --name geospatial python=3.6
conda activate geospatial
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install --channel conda-forge scipy ipykernel xarray matplotlib seaborn cartopy Pillow pysal pyproj gdal shapely descartes pyshp geopandas rasterio fiona netCDF4 us