Skip to content

Installation

Bich N Tran edited this page Oct 18, 2022 · 6 revisions

Python set up

IHEWA Python tools is developed in Python 3.7 environment. We recommend Anaconda3 distribution of Python for simple Python environment and packages manager.

Install Anaconda3

We suggest to install Anaconda3. It is a free and open-source distribution of the Python and R programming languages for scientific computing (data science, machine learning applications, large-scale data processing, predictive analytics, etc.), that aims to simplify package management and deployment. After installing Anaconda3, a Python 3.7 environment must be created since the base environment of the latest Anaconda release is 3.8. First, start Anaconda prompt with Run as administrator.

Start Anaconda prompt

In Anaconda prompt, type in the command:

conda create python=3.7 --name ihewa

To activate this environment, use the command:

conda activate ihewa

Install Python package dependency

The following table lists most of the important packages required. The full list can be found from “requirements.txt” file in the package repository. To install these packages, open Anaconda prompt and activate the working environment (Python 3.7). Then, run the installation command provided in the ‘Installation command” column of the table. Download packages

Install GDAL and setting the GDAL path

GDAL is used as the core engine to dealing with geospatial data. If you have not installed GDAL before or if you start from a clean installation of Anaconda, then GDAL should be installed before python can use it. Follow the following steps to install GDAL.

Download GDAL binary files

GDAL can be found from different places.

The following steps are to install GDAL from the binaries downloaded from Tamas Szekeres’ window binaries solution.

  1. Before download the binary files, check which version you need. This is concerned with the MSVC version used to compile python and the windows version. Open command window or Anaconda command and python to start python.

MSC and Windows version

The version number from the screenshot is v.1916 and the operating system is 64 bit (AMD64). MSC v.1916 corresponds to MSVC 2017 (see https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B).

  1. Find the corresponding binaries from the link http://www.gisinternals.com/release.php. For the above case, the corresponding link is as shown below in the screenshot.

GDAL stable releases

Selecting a release will take you to a new screen promoting a handful of EXE and MSI files. First, download and install the core components of GDAL which is the MSI file corresponding to your python setup. For the above case, the corresponding MSI file is as shown in the screenshot below.

GDAL MSI

Install the GDAL core MSI file

After downloading the installation msi file, double click it and the installation will start.

GDAL Installation screen 1

Select Complete option.

GDAL Installation Screen 2

Setting the GDAL path

After installing GDAL, the next step is to set system path of GDAL, where the system can find the executable files and the data. If you install GDAl from windows binaries, the default installation path is C:\Program Files\GDAL.

  1. Open Control Panel
  2. Go to System
  3. Find the Advanced system settings on the left side panel
  4. Click it then a system properties window will pop up
  5. Under Advanced tab, click the Environment Variables button to open the Environmental Variables window
  6. Select path in the users variable and click on Edit… to open the Edit environmental variable window
  7. Click New and add the GDAL path C:\Program Files\GDAL

Set GDAL path

  1. Close the above window and click Edit… under the System Variable to open the Edit System variable window
  2. Add a path variable called GDAL_DATA and set the value to C:\Program Files\GDAL\gdal-data

Set GDAL_DATA path

GDAL_DATA

  1. Add the same way GDAL_DRIVER_PATH

GDAL_DRIVER

Validate GDAL installation

To validate the installation, open cmd and type

gdalinfo --version

Validate GDAL

If you see the gdal version information, the installation is successful

Install the python wrapper of GDAL

  1. Download python wrapper from the same website. The installation MSI file should fit the python version on your system.
  2. Install the wrapper.

Python wrapper

  1. Validate gdal import. Open the cmd or Anaconda prompt and start python. Inside the python running environment import gdal.

import gdal

IHEWAcollect package installation

IHEWAcollect package is hosted on the Python Package Index (PyPI) repository and can be installed using pip packages manager

Install IHEWAcollect package

  1. From PyPi: IHEWAcollect is hosted on PyPi as a python package. To install it from PyPi, type pip install IHEWAcollect. All the dependencies will be installed automatically.
  2. From source code: First clone the source code from github repository. Under the root folder of the repository type python setup.py install.