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 23263
1 vote
0 answers
780 views

Running algorithms in PyQGIS (QGIS 3) [duplicate]

I'd like to use PyQGIS to run algorithms from the toolbox in QGIS 2.99 but runalg does not seem to be known. …
BritishSteel's user avatar
  • 6,657
3 votes

Using PyQGIS, how do you project a shapefile from EPSG:4326 to 3857?

You can use the Reproject Layer algorithm from the processing toolbox. Let's assume you have a cities.shp in a folder named testing, and you want to create a new file cities_prj.shp that is transform …
BritishSteel's user avatar
  • 6,657
4 votes
Accepted

How may I use Umlaute programmatically to show up correctly in PyQGIS messagebar?

Two steps: - add a line that indicates UTF-8 encoding to the top of your script - add the letter u (to indicate unicode) before the string that contains the umlaut For example, the following snippet: …
BritishSteel's user avatar
  • 6,657
1 vote
0 answers
229 views

QgsExpression.evaluate() is deprecated from PyQGIS?

I am developing a plugin for QGIS 2.18 and I am sending queries to a layer: self.userLayer.startEditing() for feature in self.userLayer.getFeatures(): value = expression.evaluate(feature) fe …
BritishSteel's user avatar
  • 6,657
2 votes
Accepted

Global name canvas is not defined

You are calling the wrong class. What you need to call is mapCanvas, and not canvas. Change your code to this: allLayers = iface.mapCanvas().layers() for i in allLayers: print i.name() This wi …
BritishSteel's user avatar
  • 6,657
1 vote
1 answer
185 views

Opening the PyQGIS editor programmatically

I can open the console programmatically, using: qgis.utils.iface.actionShowPythonDialog().trigger() Is there a way to additionally open the console's editor (the window where you can enter multiple …
BritishSteel's user avatar
  • 6,657
1 vote
1 answer
650 views

Creating a memory layer without the CRS dialog in PyQGIS 3

I am trying to create a memory layer: tempLayer = QgsVectorLayer('LineString', 'my_temp_layer', 'memory') But as soon as this line is excecuted (not when I add it to the map!) the CRS dialog pops u …
BritishSteel's user avatar
  • 6,657
9 votes
2 answers
2k views

Using memory layer as input and/or output with runalg?

Can a memory layer be used as an input and/or output with runalg? With runandload I get this to work: processing.runandload("qgis:mergevectorlayers","memory:bufferOne", "memory:bufferTwo", r"memory …
BritishSteel's user avatar
  • 6,657
4 votes
2 answers
3k views

Why use QgsFeatureRequest() when iterating?

I am unclear on why one should use QgsFeatureRequest() when iterating over a file’s features. Let’s say I would like to print out all IDs in my currently active dataset. Now, most examples will provi …
BritishSteel's user avatar
  • 6,657
13 votes
Accepted

User Interface file compilation using OSGeo4W shell during qgis plugin creation

I will write a quick explanation of the pyuic4 and pyrcc4 commands for future reference. Most tutorials simply tell you to copy some code, but no one explains exactly what you are about to do. It is q …
BritishSteel's user avatar
  • 6,657
5 votes

Split feature by line in PyQGIS

A simple way would be using The polygon-line intersection tool from the SAGA toolbox. This would work: import processing polys = QgsVectorLayer(r"C:\PyQGIS_Test\polys.shp", 'poly', 'ogr') lines = Qg …
BritishSteel's user avatar
  • 6,657
9 votes
Accepted

How to access a specific feature?

You could access the specific feature, without a loop, using the setFilterFid() method. In your case, if you wanted to call the feature in row 222, you would do: aLayer = iface.activeLayer() reques …
BritishSteel's user avatar
  • 6,657
11 votes
Accepted

Loading CSV data table as Vector layer using PyQGIS

The following snippet works for me: uri = "file:///C:/testdata/somecsv.csv?delimiter=%s" % (";") lyr = QgsVectorLayer(uri, 'New CSV','delimitedtext') QgsMapLayerRegistry.instance().addMapLayer(lyr) F …
BritishSteel's user avatar
  • 6,657
4 votes
1 answer
118 views

Getting only joined fields using PyQGIS

I am not performing the join via PyQGIS. The join is done manually and I would just like to use PyQGIS to detect which fields have been joined. …
BritishSteel's user avatar
  • 6,657
21 votes

Reading attribute values using PyQGIS

In order to get the information in a table you would first have to access the layer's features. In my case, I put the features in a variable. Then you loop through the features, and for each feature y …
BritishSteel's user avatar
  • 6,657

15 30 50 per page