Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 197647
5 votes
2 answers
416 views

Getting the value of OSM tag contained in the 'other_tag' field using PyQGIS

I got my data from OSM and a lot of metadata is stored in field "other_tags", which is in itself an HSTORE key/value field. For instance, my "other_tags" contains a key voltage with value "150000" as …
Mar Tijn's user avatar
  • 533
1 vote
1 answer
350 views

Creating QgsFeatureSink without using parameterAsSink

I know I can create a (QgsFeatureSink, string) tuple by calling (sink, dest_id) = self.parameterAsSink(...) However that requires me to pass an output layer as a parameter: self.addParameter( Qgs …
Mar Tijn's user avatar
  • 533
2 votes
Accepted

Creating QgsFeatureSink without using parameterAsSink

As per Ben's suggestion, you can use createFeatureSink as a drop-in replacement. The only thing to be aware of, is to use memory: as destination URI. Something that seems to be missing from the offici …
Mar Tijn's user avatar
  • 533
0 votes
Accepted

PyQGIS outside GUI: module 'qgis.processing' has no attribute 'run'

This answer is posted here: Looking for manual on how to properly setup standalone PyQGIS without GUI At the time of writing I didn't know the two were related. …
Mar Tijn's user avatar
  • 533
4 votes
2 answers
234 views

Rename layer after gdal:rasterize

I rasterized a layer using gdal:rasterize like this: raster = processing.run( "gdal:rasterize", {...}, is_child_algorithm=True, context=context, feedback=feedback ) But gdal:raste …
Mar Tijn's user avatar
  • 533
5 votes
2 answers
3k views

PyQGIS outside GUI: module 'qgis.processing' has no attribute 'run'

When trying to use processing.run() from a standalone (no GUI) mode, I get the following error: module 'qgis.processing' has no attribute 'run' in the following trivial example: from qgis import pro …
Mar Tijn's user avatar
  • 533
3 votes
1 answer
367 views

PyQGIS custom application: no GUI appearing

I'm following the following instructions on getting Python to work with QGIS, outside the QGIS GUI itself: Using PyQGIS in custom applications. …
Mar Tijn's user avatar
  • 533
8 votes
1 answer
660 views

Getting QgsVectorLayer from QgsFeatureSink

I have created a feature sink like so: (sink, dest_id) = self.parameterAsSink(...) And added a number of features to it. When I'm done processing, I want to post-process this layer using gdal:rasteri …
Mar Tijn's user avatar
  • 533
4 votes
2 answers
3k views

Looking for manual on how to properly setup standalone PyQGIS without GUI

My goal is to create a standalone PyQGIS script that is able to run QgsProcessingAlgorithm scripts without GUI. My setup runs on Windows and my IDE of choice is VS Code. …
Mar Tijn's user avatar
  • 533
2 votes
Accepted

Looking for manual on how to properly setup standalone PyQGIS without GUI

And to ensure future versions of me, and other people who would love to not go through all these loops and hoops and instantly test their scripts in PyQGIS without GUI, I've created a GitHub repository … with a simple example. https://github.com/MarByteBeep/pyqgis-standalone It doesn't rely on a batch file to launch VS Code and I modified the settings in such a way that it would be relatively easy to …
Mar Tijn's user avatar
  • 533
1 vote

How to setup Visual Studio Code (Windows) for PyQGIS 2 or 3?

Since it's 2022 now and some things that were mentioned here have changed, I decided to create a repository with a test example here: https://github.com/MarByteBeep/pyqgis-standalone The full explanation … can be found here: Looking for manual on how to properly setup standalone PyQGIS without GUI …
Mar Tijn's user avatar
  • 533