Skip to content

Guide to the added Code

Sandeepan Dhoundiyal edited this page Sep 9, 2022 · 20 revisions

A guide for the code added during GSoC-22

This repository consists of two branches:

1. The main branch

The main branch consists of all the code written during the summer. Much of it was written as learning exercises to familiarise myself with the Zoo-Project, docker, and QGIS python console.

2. The gsoc22 branch

The gsoc22 branch removes much of the redundant code and the aforementioned exercises (such as hello-world scripts). It reorganizes the files from the main branch into a more understandable structure. This page provides an overview of this structure and documentation on using this code.

It primarily consists of five parts:

  1. Installing the ZOO-Project and QGIS

  2. Exporting the tools in the QGIS processing toolbox and making them accessible through Python using the files created in the previous step.

  3. Automating these steps through a bash script and creating a docker image for these steps.

  4. Documentation of the three services created during this project.

  5. Documentation of the services partially implemented during this GSoC as well as descriptions of additional services which maybe implemented in the future.

1. Installing the ZOO-Project and QGIS

The Zoo-project can be setup by following these steps:

1.1. clone the Zoo-Project repository

git clone https://github.com/ZOO-Project/ZOO-Project.git
cd ZOO-Project

1.2. Inside the ZOO-Project directory, replace the contents of the docker-compose.yml with this code

1.3. Now head to the docker directory and change the contents of the main.cfg file with the this code

1.4. Build the docker image

sudo docker compose

1.5 The instance of the ZOO-project can then be accessed at localhost

Steps 1.2 and 1.3 are required if there is another application already using port 8888. This bash file consists of the other commands and can be implemented to install the Zoo-Project and build the image

QGIS can be installed using the apt-get command. Perform the following steps:

1.6 Update the list of apt packages

sudo apt-get update

1.7 install QGIS along with matplotlib and scipy

sudo apt-get install qgis python-matplotlib python-scipy

This bash file consists of both commands and can be run instead.

2. Exporting the tools in the QGIS processing toolbox and making them accessible through Python using the files created in the previous step.

2.1 Accessing the QGIS processing toolbox requires that the paths for these tools be saved so they can be accessed without the QGIS GUI. This is achieved by running this code in the QGIS python console.

2.2 The tools exported from QGIS can be imported into QGIS by running this script in a python file where these functions are needed.

3. Automating these steps through a bash script and creating a docker image for these steps.

The two bash scripts mentioned in the previous step are used to automate the process and are repurposed when a docker image is created.

This consists of the following steps;

3.1 get the ubuntu base image

FROM ubuntu:18.04

3.2 set the paths for using miniconda

ENV PATH="/root/miniconda3/bin:${PATH}"
ARG PATH="/root/miniconda3/bin:${PATH}"

3.3 install miniconda

RUN apt-get update
RUN apt-get install -y wget && rm -rf /var/lib/apt/lists/*
RUN wget \
RUN wget \
    https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && mkdir /root/.conda \
    && bash Miniconda3-latest-Linux-x86_64.sh -b \
    && rm -f Miniconda3-latest-Linux-x86_64.sh 
RUN conda --version

3.4 get and run the bash scripts for installing the Zoo-Project and QGIS

RUN mkdir -p /var/zooqgis
WORKDIR /var/zooqgis
copy ./ /var/zooqgis
RUN conda install numpy
conda install -c conda-forge qgis
RUN sudo bash install_ZOOProject.sh
RUN sudo bash install_QGIS.sh

These commands are compiled into this docker file

4. Documentation of the three services created during this project.

Three services were implemented as a part of this GSOC:

4.1. Affine Transform

The function implementing the affine transform is linked here. The config file for this service is linked here. The detailed description of the QGIS function is given here

4.2. Centroid of Polygons

The function implementing estimates the centroids for polygons in a layer is linked here. The config file for this service is linked here. The detailed description of the QGIS function is given here

4.3. Topological Coloring

The function implementing the affine transform is linked here. The config file for this service is linked here. The detailed description of the QGIS function is given here

5. Documentation of the services partially implemented during this GSoC as well as descriptions of additional services which may be implemented in the future.

In addition to the services listed above, the following four services were also implemented:

5.1.1 Kernel density estimation: Details here

5.1.2 Sampling Points inside polygons: Details here

5.1.3 Randorm selection of features: Details here

Additionally, details for five services were also compiled. These are;

5.2.1 IDW interpolation. Details Here.

5.2.2 Triangular Irregular Network (TIN). Details Here.

5.2.3 Contour To Polygon. Details Here.

5.2.4 KNN based Concave Hull. Details Here.

5.2.5 Statistics by category. Details Here.

These descriptions were compiled using this python script.