Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Join us in building a kind, collaborative learning community via our updated Code of Conduct.

The tag has no usage guidance.

1
vote
0answers
9 views

QGIS 3 crashes when QgsExtentGroupBox.setOriginalExtent() is called

Below is the relevant code. I am using QgsProjectionSelectionWidget to get the CRS. canvas_extent = self.canvas.extent() transformer = QgsCoordinateTransform( self.canvas.mapSettings(...
0
votes
0answers
6 views

QGIS 3.0 migration - unable to install PyPDF2

I am migrating my Plugin to QGIS 3.0. Currently a bit stuck trying to install PyPDF2. I have been trying different things for the last couple of hours or more, without success. I have got another ...
0
votes
1answer
13 views

Creating and manipulating an HTML frame in QGIS3 Print Composer using PyQGIS

I'm trying to create, reposition and resize an HTML frame in a QGIS3 Print Composer layout using PyQGIS: proj = QgsProject.instance() comp = QgsPrintLayout(proj) blockStats = QgsLayoutItemHtml.create(...
0
votes
1answer
25 views

Problem running PyQt code in Qgis3

I am in my first steps in PyQt and I face difficulties in how to run the following code within QGIS console. I want to create a simple window, but nothing happens. I change main by console and then ...
0
votes
0answers
18 views

Where to put new tool function and how to call it?

I code a small plugin to get parcels numbers from the canvas to the QPlainTextEdit object in my dockwidget. I found nice piece of code in topic Getting attribute value from vector layer after mouse ...
1
vote
1answer
41 views

Error: Algorithm not found with correct processing use

I try to run a simple dissolve algorithm in a standalone Python 3 script. My code is following : from qgis.core import QgsVectorLayer import processing from processing.core.Processing import ...
0
votes
0answers
10 views

Changing name of outputlayer dynamically in QGIS Processing script?

I have a processing script to load txt-data from a magnetometer and convert them into a vectorlayer (to make a raster in a second step). I want the name of output layer to be changed into something ...
0
votes
0answers
10 views

QGIS 3: Changing the datasource of a layer?

Everything seams to go right, but nothing happens: layers = QgsProject.instance().mapLayers().values() for layer in layers: if isinstance(layer, QgsVectorLayer): dp = layer.dataProvider() ...
0
votes
0answers
27 views

Using Python to set text for a label in a QGIS3 print layout label

I am able to assign a QGIS 3.2 print layout label item to a Python variable using: MyMapLabel = MyPrintLayoutObject.itemById('MyLabelName') Which is all well and good but I need to be able to change ...
0
votes
1answer
23 views

Saving image to variable using PyQGIS

I'm generating an image from QgsComposer composition through QgsLayoutExporter.exportToImage() method that allows to save the image to disk. I wonder if there is any way to get image binary data into ...
0
votes
1answer
36 views

How to open saved QGIS layout in layout designer with Python?

Is it possible to open saved layout in layout designer(print composer) with Python? QGIS Python API: openLayoutDesigner(self, layout: QgsMasterLayoutInterface) → QgsLayoutDesignerInterface ...
1
vote
0answers
18 views

pyqgis: release all image locks

I have a QGIS 3.2 workflow that helps me to mass produce image classiication labels for some deep learning work. The workflow creates multiple files with various prefixes in tif format. At the end ...
1
vote
0answers
9 views

Improve performance of QgsVectorLayerDirector.makeGraph() in PyQGIS 3

Porting a plugin that makes excessive use of PyQGIS networking capabilities I had to realize, that building the graph (makeGraph() method of class QgsVectorLayerDirector) in PyQGIS 3 (https://qgis.org/...
2
votes
2answers
38 views

How extract the polyline length in PyQgis 3.0?

I wrote the following code in order to automatically extract the objects' length of a line layer, but I think the « measureLine » expression is not working. This expression works very well PyQgis 2.0. ...
2
votes
0answers
25 views

“gdal:cliprasterbymasklayer” not clipping to polygons in QGIS3

I'm working on a plugin for QGIS3, and trying to clip a raster layer using a vector mask layer containing many polygons. I've been able to successfully do this using "Clip raster by mask layer" ...
2
votes
1answer
37 views

QGIS 3 - Python : QgsVectorLayerJoinInfo issue

I'm trying to use Python to join a table to a vector layer within QGIS (v. 3.2.0) Here is the script I use : >>>root = QgsProject.instance().layerTreeRoot() >>>ids = root....
1
vote
1answer
35 views

Paths layers disappear on map after saving in QGIS 3

I am quite new to GIS and extremely struggling with the following issue. I am working on a historical map with three sets of points. When I create a path between those points with the "Points to Path" ...
1
vote
1answer
38 views

How to fill fields with layer name in PyQGIS

I have hundreds of shapefiles that I have added to a QGIS project. I am using QGIS 3.0.0. I have created a new text field for each of them named 'Enumertr' in PyQGIS and I need to populate this field ...
1
vote
0answers
19 views

Make QgsVectorLayer().getFeatures() ignore an existing filter

When retrieving features from a layer with PyQGIS by sth. like feat = [f for f in my_lyr.getFeatures('"road_name" = \'myroad\'')] the resulting feat list is empty in cases where a filter is applied ...
0
votes
1answer
33 views

Find QGIS 3 plugin folder location with PyQGIS

Background of my question: I would like to figure out the version of a plugin ('my_plugin'), in PyQGIS 2 like: from qgis.utils import findPlugins import os plugins = list(findPlugins('C:\Users\me\....
1
vote
1answer
47 views

Passing “self” when calling functions in modules from other modules using PyQGIS?

I'm building a QGIS 3.0 plugin and trying to organise my code into several files. I have three files - a main python script and two other scripts stored in a subfolder. Excerpts provided below: \...
1
vote
1answer
40 views

How to set label font color using data defined property for PyQGIS 3?

Set label font color using data defined property in PyQGIS 2 is well established, e.g. in another thread However, PyQGIS 3 completely changed the way this works with no well documented examples. So, ...
2
votes
1answer
28 views

Getting “value”, “color”, “label” from existing palette raster layer in PyQGIS?

renderer = activaterlayer.renderer() symboloyitems = renderer.legendSymbologyItems() label = symboloyitems[i][0] color = symboloyitems[i][1].getRgb() value = ? How can I get the ...
1
vote
1answer
22 views

pyqgis 3.0 : how to project raster layer, avoid pop-up prompts interface

rasterlayer = QgsRasterLayer(self.infile, layername) raster_crs = rasterlayer.dataProvider().crs() if raster_crs is None: self.rasterlayer.setCrs(QgsCoordinateReferenceSystem(4326, ...
2
votes
1answer
41 views

pyqgis: how to get the existing Paletted Raster Layers' color

rasterlayer = QgsRasterLayer(infilename, layername) renderer = rasterlayer.renderer() rasterlayer is the active layer with renderer type is Palette, I want to get current Palette Color, how could I ...
0
votes
1answer
29 views

Showing lines in shp file with different size of border depends on feature value - PyQGIS

I have shp files with lines which looks something like this: ID name weight 1 a 15000 2 b 100 3 c 450 4 d 50 5 e 10000 And I need that lines ...
1
vote
0answers
46 views

Why python function not work in custom function in QGIS 3.2?

in QGIS atlas I use a custom function to find the first file containing texts : import os, fnmatch from PyQt5.QtCore import QFileInfo from qgis.core import * from qgis.gui import * @qgsfunction(args=...
1
vote
1answer
22 views

Http Request in Qgis3 Plugin

I need to do some HTTP request based on feature in PyQGIS. Based on http://zetcode.com/pyqt/qnetworkaccessmanager/ I created this class: from typing import Callable from PyQt5.QtNetwork import ...
1
vote
1answer
77 views

How to set background color of label using PyQGIS 3?

suppose I have a shapefile that have an attribute, and I want that attribute to be shown with white background behind the text in the viewport. This is what I want to accomplish: I've searched the ...
2
votes
1answer
87 views

How can I get the path for an input layer in a QGIS 3 script?

Writing scripts in previous versions of QGIS, I would get the layer path to pass to algorithms using processing.getObject(layer). In QGIS 3, the scripting system has been rewritten, and I now define a ...
1
vote
1answer
75 views

Where to find documentation on algorithm parameters when writing scripts in QGIS 3?

For older versions of QGIS, the algorithm parameters were documented in the 'Console usage' section in the QGIS documentation (e.g. the reproject layer documentation). In the QGIS 3 documentation (e.g....
1
vote
2answers
36 views

exec(open('/tmp/tmpu7edmqsu.py'.encode('utf-8')).read()) on PyQGIS 3

I tried to load csv layer using this script: file = "/home/ayato/Desktop/26mei.csv?delimiter=%s&xField=%s&yField=%s" uri = file % (",", "x", "y") vlayer = QgsVectorLayer(uri, "asd", "...
1
vote
1answer
66 views

Can get PyQGIS 3 map to display in PyQt5 standalone app or menus, but not both

I can run a standalone app but no map shows up, but different from a similar question last year. The code posted last year works for me after editing QGISHOME to Win 10 system (r'c:\OSGeo4W64\apps\...
0
votes
0answers
63 views

pyqgis 3 QgsApplication.initQgis failed due to Qt5Core.dll crash

I have an existing pyqgis standalone application that was developed using python2.7 and Qt4. Now that Qgis 3.0 has come out, I am trying to get it to run in Python 3.6 and Qt5. I've made a clean ...