Making the process of cleansing and improving the dataset of Montreal buildings' footprints automated with a programming approach. This will be done in Python.
Go to file
2024-08-07 15:39:32 -04:00
.idea Replace load_layer module with load_layer function in the main workflow file 2024-02-15 09:45:31 -05:00
services_scripts Split to five files 2024-08-07 15:38:34 -04:00
.gitignore Update gitignore 2024-08-07 15:39:32 -04:00
init.py Add init.py 2023-11-30 11:31:20 -05:00
mtl_buildings_workflow.py Add a field which is holding the area of each record (the workflow) 2024-03-12 16:20:55 -04:00
README.md Edit readm.md 2024-02-15 10:35:35 -05:00
standalone_vs.py Add gitignore & pyqgis boilerplate 2023-12-14 13:26:42 -05:00

Table of Contents

About GISPy
mtl_buildings_workflow.py
standalone_vs.py
Setting up an environment to use standalone PyQGIS How to import qgis.core

About GISPy

This project automates the process of integrating and cleaning updated datasets related to Montreal buildings. The project involves the following datasets:

  1. NRCAN Building Footprints
  2. Shared platform of geospatial data and aerial photographs (GeoIndex)
  3. Montreal Property Assesment Units
  4. Administrative boundaries of the agglomeration of Montréal (boroughs and related cities)

The workflow has been developed and implemented in ArcGIS. This workflow (link) involves steps such as fixing geometries, clipping unnecessary parts of the map, splitting sections based on single building footprints, spatially joining datasets, and cleaning the data through processes such as removing duplicates, among others.

GISPy integrates these processes and automates them so that users can update the dataset by running the workflow module (mtl_buildings_workflow.py) after acquiring and defining the paths to the mentioned datasets.

GISPy has been written using QGIS Python standalone libraries (PyQGIS). This set of libraries leverages the functionality of QGIS without needing to run the full QGIS desktop application. To use the environment, QGIS needs to be installed, and the environment must be set up (Setting up an environment to use standalone PyQGIS How to import qgis.core).

mtl_buildings_workflow.py

This is the main Python module. After defining the paths, running the module outputs the updated and integrated dataset (map layer).

standalone_vs.py

This module provides the preliminary settings for using PyQGIS.

Setting up an environment to use standalone PyQGIS How to import qgis.core

#pyqgis #qgis #path #pythonpath

To use PyQGIS without having the QGIS application run in the background, one needs to add the python path to the environment variables. Here is how to do it on Windows:

  1. Install QGIS

  2. Assign a specific name to the QGIS Python executable: This is being done in order to access the QGIS Python from the command prompt without mixing with the systems original Python installation(s).

    a. Go to the QGIS installation directorys Python folder. e.g. C:\Program Files\QGIS 3.34.1\apps\Python39
    b. Duplicate the Python executable (python.exe) by copy-pasting it
    c. Rename the duplicated version. e.g. pythonqgis.exe

  3. Updating the Path variables

    a. Go to Environmental Variables (from Windows start)
    b. Click on Path and then click on Edit. Add the following paths:

    i. C:\Program Files\QGIS 3.34.1\apps\Python39\pythonqgis
    ii. C:\Program Files\QGIS 3.34.1\apps\Python39

    c. Go back to the Environmental variables this time click on New and in New Variable box enter PYTHONPATH and in the Variable Value add the following paths (separate them with a colon). Some paths might be different. For example, apps\qgis can be apps\qgis-ltr.

    i. C:\Program Files\QGIS 3.34.1\apps\qgis\python
    ii. C:\Program Files\QGIS 3.34.1\apps\qgis\python\plugins
    iii. C:\Program Files\QGIS 3.34.1\apps\Qt5\plugins
    iv. C:\Program Files\QGIS 3.34.1\apps\gdal\share\gdal
    v. Or altogether: C:\Program Files\QGIS 3.34.1\apps\qgis\python;C:\Program Files\QGIS 3.34.1\apps\qgis\python\plugins;C:\Program Files\QGIS 3.34.1\apps\Qt5\plugins;C:\Program Files\QGIS 3.34.1\apps\gdal\share\gdal

  4. Validate importing qgis.core

    a. Open a command prompt window b. Enter pythonqgis
    c. If the process has been done correctly, you wont face any error.
    d. In the Python environment, import the package by:

    i. Either import qgis.core
    ii. Or from qgis.core import *