New answers tagged scripting
This script selects at the very end all features being part of multiple combinations. It finds #2309. I have extended the list by an adress PID 3459, STREET Oxford, to deal with cases, where PIDs border at streets with equal AND different names (3x Main, 1x Oxford). Properties with all NULL attributes are ignored. # get reference to the layer layer = ...
If you don't want to rename the layer, you could use the following code to load the output that's saved directly into your map project and assign it any name you wish. No need to use runandload and the only two parameters that you may want to change would be the name and the directory in the path: from qgis.core import QgsMapLayerRegistry, QgsVectorLayer ...
Turns out (on a Mac at least) you have to put the full path plus the name for your file. For example, the following code places the output shapefile "MyFile" on my desktop. path = "/Users/User1/Desktop/" processing.runandload('qgis:saveselectedfeatures', Input, path+'MyFile.shp') Seems obvious in hindsight but again better documentation in the Help tab ...
The solution I ended up using was to replace "selectbyattribute" "selectbyexpression" and place it in a loop, each time iterating through my list of streets and adjusting my "expression" accordingly. processing.runalg('qgis:selectbyexpression', Input, expression, 1) Setting "1" as the third attribute adds to the current selection.
self refer to the instance of the class you have to load to make any QGIS plugin work e.g this example file. In the console, you don't need the self stuff as you don't use the same loading mechanism as in a QGIS plugin. self isn't specific to QGIS, it's a convention when doing object oriented programming with Python. You can look at some Python course to ...
The answer is to replace 'runalg' with 'runandload' (as suggested by @Joseph). Many thanks.
I would try this: '"STRNAME" = ' + "'Main'" The trick is to concatenate two strings together, and since each of the strings contains either a single or a double quote, you need to wrap it inside a pair of the opposite type of quotes. For the selectbyexpression, as you have commented, this would be the equivalent: ...
The wonderful thing about open source is that it's possible to answer an interesting question like this when it arises ;) A large part of QGIS is in C++, but surprisingly large amounts are also written in Python, including Processing. Processing is technically a Python plugin, although it's been 'brought into core' - made into a standard feature. You can ...
No you can't. mapLayersByName returns a list of layers matching a single name (you can have many layers with the same name) setActiveLayer takes a single active layer because there is only one active layer at a time in QGIS.
Top 50 recent answers are included