This post was originally written prior to setting up the conda virtual environment.
Introduction
The full suite of capabilities that come with Karttur’s GeoImagine Framework requires that you install some extra python packages with Anaconda. Which packages to install depends both on the Anaconda distribution and version, as well as the GeoImagine Framework packages.
If you have setup the GeoImagine Framework with a conda virtual python environment you probably already have all the required python packages installed.
If you are going to download data from https://earthdata.nasa.gov (e.g.SMAP or MODIS) you must also setup your machine to handle wget, as explained towards the end of this blog.
Conda virtual environments
it is strongly recommended to setup your Python interpreter using conda virtual environment as described in a previous post.
If, for some reason, you want to create an empty virtual environment instead, open the terminal and write the command:
$ conda create –no-default-packages -n geoimagine0 python
where geoimagine0 is the name of the virtual environment.
Activate the virtual Python environment by typing:
$ conda activate geoimagine0
You can now install any packages to your virtual environment using eg. $ conda install or $ pip install.
Core (default) packages
With a full installation of the Framework and Anaconda3 installed with Python 3, you need to add the following default Python packages:
- numpy
- scipy
- pandas
- geopandas
- rasterio
- psycopg2
- statsmodels
- numba
- xmltodict
If you followed the manual on setting up a virtual Python environment in conda, these are the same packages as listed as defaults when setting up a virtual environment. You should thus already have then installed. If not, you can also install the above packages into an (empty) existing virtual environment. It is best to install all packages at once, so that all of the dependencies are installed at the same time.
Activate the virtual environment you want to use (e.g. geoimagine0)
$ conda activate geoimagine0
and then install all the core packages:
(geoimagine0) … $ conda install numpy scipy pandas geopandas rasterio psycopg2 statsmodels numba xmltodict
Packages installed with the above commands
Installing the default packages above, results in a long list of also other packages, called dependencies, that are also installed. The trick is that all will be installed using shared resources and there will not be any conflicts between different versions. A full list of installed packages are reported at the prompt, or you can use conda to list all packages installed with a particular virtual environment:
(geoimagine0) … $ conda list
Some of the additional packages installed with the command above include the following packages (among others) for spatial data processing:
- GDAL
- fiona
- shapely
- pyproj
- proj4
If you want to explore other Python packages for spatial data processing please have a look at this excellent web page.
Additional packages required
Apart from the above packages, you also need to install some packages using other channels as well as other installation managers. The additional packages that are needed include:
- landsatxplore
- plotnine
- pypng
- reportlab
- seasonal
- sentinelsat
- stldecompose (LOESS decomposition)
- svgis
- svgwrite
- wget
landsatxplore
Landsatxplore is a package for searching and downloading Landsat satellite image scenes from EarthExplorer. There are alternative packages that can be used for the same task, but Karttur’s GeoImagine Framework is set up for using Landsatxplore. If you want to use Landsat data from EarthExplorer you need to register as an EarthExplorer user.
Landsatxplore is not available at any conda channel and you need to use the pip installation manager.
$ pip install landsatxplore
plotnine
plotnine is a powerful graphics editor that you can use for composing maps and layouts in Python. It is like a Python version of the popular “Grammar of graphics” concept used by ggplot. The grammar allows users to compose plots by explicitly mapping data to the visual objects that make up the plot. plotnine is available on several conda channels, and can for instance be installed using the command:
$ conda install -c conda-forge plotnine
pypng
The Pure Python PNG (pypng) image encoder/decoder is a stand alone module that is used for writing png images. In the Framework, pypng is used both for generating image maps, including movie frames, and other graphical output (e.g. legends). Use pip install to get pypng added to your project.
$ pip install pypng
reportlab
Reportlab is not used in the present FRamework version. It can be used for generating pdf outputs, mainly for creating map legends.
if you want to install reportlab make sure it can be installed without conflicts using conda:
$ conda install -c anaconda reportlab
reportlab is also available as pip install
$ pip install reportlab
seasonal
The seasonal package estimate and remove trend and periodicity in time-series. In the Framework it is used for time-series decomposition and trend estimations.
NOTE that in the Framework the seasonal package is edited to include more options and with altered default settings.
The seasonal package is installed with pip install
$ pip install seasonal
sentinelsat
In the Framework Sentinelsat is used for searching, downloading and retrieving the metadata and the actual data of Sentinel satellite images from the Copernicus Open Access Hub.
Sentinelsat is installed with pip install.
$ pip install sentinelsat
svgis
SVGIS converts vector geodata to Scalable Vector Graphics (SVG). SVG can be styled using Cascaded Style Sheets (CSS) and also read and manipulated by drawing programs. In the Framework SVGIS is primarily used for exporting vector data to use as overlays in map layouts.
SVGIS is installed with pip install
$ pip install svgis
svgwrite
SVGwrite is a more general library for writing SVG formated vector graphics. It is used for creating legends and other layout items for maps. The preferred installation is using conda:
$ conda install -c omnia svgwrite
svgwrite is also available as pip install
$ pip install svgwrite
wget
Wget is a command-line tool for retrieving files using HTTP, HTTPS, FTP and FTPS (the most widely-used Internet protocols). In Karttur´s GeoImagine Framework, wget is used for accessing online available data from e.g.https://earthdata.nasa.gov, including MODIS and SMAP. To install Wget on Mac osx you can use Homebrew.
$ brew install wget
The installation of Homebrew itself is covered in the blog post on ImageMagick.