Standalone PyQGIS application for executing custom scripts without a QGIS GUI.

Overview

PyQGIS Standalone Script Executer

Standalone PyQGIS application that is able to run a custom script, in this case Proximity.py without the need of a GUI. Also we don't need to set all kinds of environment variables using a batch file: just launch the VS Code project, and off you go. This was created for Windows.

Installation

First get OSGeo4W LTR by running install/qgis_deploy_install_upgrade_ltr.ps1 from PowerShell console with administrative rights. Ensure to fetch QGIS LTR. This script will automatically download and install OSGeo4W. You can obviously do this manually as well. Just ensure you get QGIS LTR and the full installation. Also ensure to install everything in C:/OSGeo4W. If not, change the paths in .env and .settings.json, see below.

Access Rights

If the script is failing because of accessrights, you need to temporarily bypass the ExecutionPolicy

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Verify .env

Open up .env in the root folder and verify that following settings match your installation:

OSGEO4W_ROOT=C:/OSGeo4W
QGIS_CONFIG=qgis-ltr
PYTHON_VERSION=Python39

Verify settings.json

Open up .vscode/settings.json and verify that the path in python.defaultInterpreterPath exists. If it doesn't, update it to match your configuration. You probably need to update PYTHON_VERSION in .env as well.

Run example

I've included an example geometry in the test folder: it contains a number of airports in the netherlands. From VS Code select the Launch configuration and hit F5. It'll execute main.py, which in turn executes the Proximity.py script on that test geometry and outputs a rasterized tif.

This should be enough to get you going. Enjoy!

Credits

This is based on work by @isogeo: https://github.com/isogeo/isogeo-plugin-qgis/blob/master/.vscode/settings.json as well as various posts on the QGIS stackexchange forum and in particular Kadir Şahbaz: https://gis.stackexchange.com/questions/421329/pyqgis-outside-gui-module-qgis-processing-has-no-attribute-run

Wishful thinking

It would be great if the QGIS team at one point in the future, would integrate all this in their API/SDK to make this whole process seamless :)

You might also like...
Pardus-flatpak-gui - A Flatpak GUI for Pardus
Pardus-flatpak-gui - A Flatpak GUI for Pardus

Pardus Flatpak GUI A GUI for Flatpak. You can run, install (from FlatHub and fro

python scripts - mostly automation scripts

python python scripts - mostly automation scripts You can set your environment in various ways bash #!/bin/bash python - locally on remote host #!/bi

Simple Python-based web application to allow UGM students to fill their QR presence list without having another device in hand.

Praesentia Praesentia is a simple Python-based web application to allow UGM students to fill their QR presence list without having another device in h

Package to provide translation methods for pyramid, and means to reload translations without stopping the application

Package to provide translation methods for pyramid, and means to reload translations without stopping the application

A python script providing an idea of how a MindSphere application, e.g., a dashboard, can be displayed around the clock without the need of manual re-authentication on enforced session expiration

A python script providing an idea of how a MindSphere application, e.g., a dashboard, can be displayed around the clock without the need of manual re-authentication on enforced session expiration

Shutdown Time - A pretty much useless application that allows you to shut your computer down in x time with a GUI.
Shutdown Time - A pretty much useless application that allows you to shut your computer down in x time with a GUI.

A pretty much useless application that allows you to shut your computer down in x time with a GUI. Should eventually support Windows (all versions), Linux (v2.0+), MacOS (probably with Linux, idk)

Repo Home WPDrawBot - (Repo, Home, WP) A powerful programmatic 2D drawing application for MacOS X which generates graphics from Python scripts. (graphics, dev, mac)

DrawBot DrawBot is a powerful, free application for macOS that invites you to write Python scripts to generate two-dimensional graphics. The built-in

Automation of VASP DFT workflows with ASE - application scripts

This repo contains a library that aims at automatizing some Density Functional Theory (DFT) workflows in VASP by using the ASE toolkit.

Scripts for BGC analysis in large MAGs and results of their application to soil metagenomes within Chernevaya Taiga RSF-funded project

Scripts for BGC analysis in large MAGs and results of their application to soil metagenomes within Chernevaya Taiga RSF-funded project

Comments
  • Error when importing QtCore with QGIS 3.22 (LTR)

    Error when importing QtCore with QGIS 3.22 (LTR)

    I get an error using VSCode with your approach on new QGIS LTR 3.22:

    Exception has occurred: ImportError
    DLL load failed while importing QtCore: Das angegebene Modul wurde nicht gefunden.
      File "[E:\am\dev\gisstick\gisstick_x64\VSCode\test_workspace\pyqgis-standalone-main\qtcore_test.py]()", line 1, in <module>
        from PyQt5.QtCore import QSettings
    

    I only changed your launch.json to use the ${file} variable. The error occurs also with other IDE's, like PyScripter, so may be this is an OSGeo4W problem?

    opened by amr66 2
Owner
Gamedeveloper and all round programmer with a wide range of interests.
null
A QGIS integration plugin for Kart repositories

QGIS Kart Plugin A plugin to work with Kart repositories Installation The Kart plugin is available in the QGIS Plugins server. To install the latest v

Koordinates 27 Jan 4, 2023
ICEtool - ICEtool plugin for QGIS

ICEtool ICEtool is an all in one QGIS plugin to easily compute ground temperatur

Arthur Evrard 13 Dec 16, 2022
nbsafety adds a layer of protection to computational notebooks by solving the stale dependency problem when executing cells out-of-order

nbsafety adds a layer of protection to computational notebooks by solving the stale dependency problem when executing cells out-of-order

null 150 Jan 7, 2023
Blender addon for executing the operator in response to the received OSC message.

I/F Joiner 受信したOSCメッセージに応じてオペレータ(bpy.ops)を実行するアドオンです. OSC通信に対応したコントローラやアプリをインストールしたスマートフォンを使用してBlenderを操作することが可能になります. 同時開発しているAndroidコントローラ化アプリMocopa

simasimataiyo 6 Oct 2, 2022
A python script for compiling and executing .cc files

Debug And Run A python script for compiling and executing .cc files Example dbrun <fname>.cc [DEBUG MODE] Compiling <fname>.cc with C++17 ------------

null 1 May 28, 2022
Create standalone, installable R Shiny apps using Electron

Create standalone, installable R Shiny apps using Electron

Chase Clark 5 Dec 24, 2021
Create standalone, installable R Shiny apps using Electron

WARNING This is still very much a work in progress and nothing can be assumed stable in any way Temp notes: Two types of created installer, based on w

Chase Clark 5 Dec 24, 2021
Custom Weapons 3 attribute support for Custom Weapons X

CW3toX Allows use of Custom Weapons 3 attributes in Custom Weapons X. Requiremen

null 2 Mar 1, 2022
Custom SLURM wrapper scripts to make finding job histories and system resource usage more easily accessible

SLURM Wrappers Executables job-history A simple wrapper for grabbing data for completed and running jobs. nodes-busy Developed for the HPC systems at

Sara 2 Dec 13, 2021
A GUI love Calculator which saves all the User Data in text file(sql based script will be uploaded soon). Interative GUI. Even For Admin Panel

Love-Calculator A GUI love Calculator which saves all the User Data in text file(sql based script will be uploaded soon). Interative GUI, even For Adm

Adithya Krishnan 1 Mar 22, 2022