Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
4 votes
1 answer
177 views

Adding XYZ button to QGIS Manage Layers Toolbars

QGIS manage Layers toolbar offers a quick shortcut to the "data source manager". For instance, clicking on the "add raster layer" button brings me immediately to the proper tab of ...
jfmoyen's user avatar
  • 546
0 votes
1 answer
69 views

Copy layer group from one project to another with PyQGIS

Using QGIS 3.8, is there anyway to copy a layer group (and its subgroups) from project1.qgz to project2.qgz? I'm trying to write an script that adds a layer group (with several layers and group layers ...
pfrud's user avatar
  • 81
-1 votes
2 answers
95 views

Generating two points between two existing points using PyQGIS [closed]

I have the following problem: I have two points and I need a script to create two new points that are contained between the existing points and that the 4 points are collinear. I will add two images ...
Aloísio Ângelo's user avatar
1 vote
1 answer
70 views

Getting bounding box for scratch layer source using PyQGIS

I drew a New Temporary Scratch Layer, named New Scratch Layer, in QGIS. Both layer and project CRS are EPSG:3857. I am trying to compute its bounding box using PyQGIS. I use the following script: [...
zabop's user avatar
  • 2,690
1 vote
2 answers
75 views

How to group actions on a custom QGIS toolbar

I've written a custom plugin for QGIS that has several actions. I can add them separately to my custom toolbar but as the plugin grows I'd like to group several of them together in a dropdown that ...
davehughes87's user avatar
0 votes
3 answers
175 views

GeoPandas dataframe to JSON gives type error: Object of type QVariant is not JSON serializable

I'm creating a plugin and within the code I have a GeoPandas geodateframe created from a QGIS Vector layer which I need to reformat back into a QGIS vector layer. To create a vector layer from a ...
i.i.k.'s user avatar
  • 1,853
2 votes
1 answer
100 views

QGIS-Plugin: How to re-integrate QDialogButtonBox after deleting the buttons?

I'm writing a plugin for QGIS and created the basic-code according to this: https://www.qgistutorials.com/en/docs/3/building_a_python_plugin.html, so the base code is like this: https://github.com/g-...
i.i.k.'s user avatar
  • 1,853
0 votes
1 answer
122 views

Creation of QGIS Plugin: How to add comboboxes interactively

I am creating a QGIS Plugin, in which the user can rename columns to specfied names depending on a certain policy. In the image you can see, that the user selects a layer in QGIS which field names ...
i.i.k.'s user avatar
  • 1,853
0 votes
1 answer
28 views

Programmatically enable/Disable a plugin repository

I'd like to enable or disable a repository from the plugin repository with pyqgis. Exactly like when you're clicking on this checkbox in the plugin manager interface : I only find a way to remove a ...
JULESG's user avatar
  • 1,657
0 votes
0 answers
51 views

Python script problem with Qvariant

I have a problem with a pygis script. This is a script to load in a shapefile layer from a WFS source and to add 4 extra fields to the attributes: Label, Legende1, Legende2 and PercId. In one of the ...
BramV's user avatar
  • 107
1 vote
1 answer
67 views

Getting value of "Editable" checkbox in layer fields widget settings with Python?

I have been trying to find a way to check the editability state of fields within a layer in QGIS 3.34 with no luck. I've tried using QgsVectorLayerUtils calls of fieldIsReadOnly, fieldIsEditable, and ...
Evan's user avatar
  • 13
2 votes
1 answer
127 views

How to filter only active layers in QgsMapLayerComboBox

I'm filtering the layers in a QgsMapLayerComboBox and in addition to filtering according to geometry, I want to remove the layers that are disabled? Is it possible? How do I do it? I'm using the ...
Aloísio Ângelo's user avatar
0 votes
0 answers
68 views

Recalling a MainWindow from an other script on PyQGIS console

I'm writing some scripts on Python console in QGIS. I have been stuck since a lot of time because I'm not able to recall a MainWindow class object from an other script. I've created a main menu with ...
Salvatore Diolosà's user avatar
3 votes
1 answer
76 views

Layer Feature Id Number

I have a short Python action that creates a new shape file for any feature that you click on in the layer. That part all works fine. When you zoom out it will select multiple feature and give you a ...
Joe G's user avatar
  • 363
2 votes
1 answer
73 views

Plotting circle by center and radius in QGIS Python Console

Using QGIS's Python Console, I would like to be able to specify a coordinate in a given projection and draw a regular n-gon of a specific size centered on that point. I can achieve the above if the ...
zabop's user avatar
  • 2,690
1 vote
0 answers
38 views

Using pyrcc5 when OSGeo4W is not installed on C:

I am writing a plugin from QGIS that I started up using plugin builder. On a previous system my OSGeo4W was on my C: and I also had an older version of QGIS (v3.26), and I generated the resource files ...
MappingThePast's user avatar
0 votes
0 answers
37 views

Customize QgsAttributeDialog

I would like to customize the QgsAttributeDialog. I need the driving attribute to be not a textBox but a ComboBox. Is it possible to do this?
Stano's user avatar
  • 49
2 votes
1 answer
75 views

"Couldn't load PyQGIS" when launching QGIS with Anaconda

I'm trying to install QGIS in a new environment on Anaconda. Here is the command I used: conda install -c conda-forge qgis But it seems like Python couldn't work with this QGIS here when I launch ...
XXY's user avatar
  • 21
1 vote
0 answers
92 views

Transfering features and its fields a layer to another in QGIS using Python

I created my own plugin to copy and paste layers in QGIS. All functions and code are working fine, but when I select 'Copy All Fields' and then try to copy and paste the selected field, QGIS crashes ...
unknown's user avatar
  • 49
2 votes
1 answer
96 views

Adding attribute values to existing GeoPackage with PyQGIS

I have an existing GeoPackage and want to copy Features from another layer to this one using PyQGIS and execute it inside a QGIS Macro. For that, I have the following code: from qgis.core import ...
Dennis's user avatar
  • 55
6 votes
1 answer
96 views

Chaging default path for saving output layouts in QGIS

We work on a large number of projects and the file structure is normally the same so repeatedly browsing for the right location to save plans has issues. I would like to be able to change the default ...
Sethinacan's user avatar
  • 2,002
2 votes
1 answer
108 views

Position labels dynamically based on their point feature values

In QGIS I go to the layer properties and in the labels/positioning section in the 'Offset X, Y' field I click on 'Defined data overwrite' and enter the following expression: 'array("...
Wolverine's user avatar
2 votes
1 answer
84 views

Modify vertex for polygon in QGIS Python script

For a given polygon, I'd like to modify the vertex, some of them should be deleted and some of them should be updated with new coordinates. And I know exactly the index for the related vertex. The ...
giser's user avatar
  • 803
0 votes
2 answers
40 views

PyQgis: filledMarkerSymbolLayer data defined properties not transferred to marker symbol

No pressing need here - I am mostly trying to determine what symbology can and can't be modified in PyQgis as opposed to the QGis GUI. In this particular case, filled marker symbols. Qgs....
Marc Loiselle's user avatar
0 votes
0 answers
35 views

QGIS Python Script for loading MS-Server Tables and create relates and Attribute Form Widgets

I have the following Python script for QGIS3, which is supposed to load spatial and non-spatial tables into a new project. Relationships are then to be set and certain links are to be created in the ...
Immo Woschny's user avatar
2 votes
1 answer
73 views

Setting extent for screenshot via PyQGIS

I am trying to figure out how I can set the extent of the rendered image because with QgsMapSettings().setExtent it doesn't work for me. How can I set the extent as big as the biggest active vector ...
Ckoe22's user avatar
  • 21
0 votes
0 answers
44 views

Ignore the same exception multiple times and continue with code

I'm currently working on a Python 3.12.3 plugin for QGIS 3.36.2 that adds two toolbars and a layer at different stages of its code. In unload I want to remove all of them with e.g.: self.toolbar....
Neph's user avatar
  • 291
2 votes
0 answers
83 views

Filtering Projected coordinate reference systems in select CRS dialog box with PyQGIS

I am writing a PyQGIS script, where for the select CRS dialog box, I only want to show the projected coordinate Systems. Is there a way to make such a choice inside the parameter definition as ...
Mohsin's user avatar
  • 21
0 votes
0 answers
64 views

QGIS/Lizmap : Custom filter on inherited layer

I just started a new job and I get to work with Lizmap to create custom maps for each French region. To achieve this I would like to use the parent/child feature from Lizmap to create a parent project ...
Corentin's user avatar
1 vote
0 answers
70 views

Iterating through layers contained in GeoPackage with the same SubsetString using PyQGIS

I want to iterate through layers contained in a GeoPackage using PyQGIS and select features based on attributes. I use the same method on two layers in the same GeoPackage. The first correctly filters ...
RavenS's user avatar
  • 69
1 vote
1 answer
61 views

Trigger Python code with "Navigate to next feature" button on QGIS

I am creating a script in the Action feature of QGIS that plots the values of an attributed table in matplotlib when I click on a feature in a layer as shown below. class ClickTool(QgsMapToolIdentify):...
AMA's user avatar
  • 468
1 vote
1 answer
101 views

Making Python script originally produced with QGIS Modeler work on QGIS console

I'm writing some scripts on QGIS Python console, and I would like to implement some dialog windows, as those about the parameters' insertment, converting from the result of model builder, but when I ...
Salvatore Diolosà's user avatar
2 votes
1 answer
100 views

"TypeError: unsupported operand type(s) for /: 'QVariant' and 'int'" when automatically updating with PyQGIS

Using the Python Console I would like to update multiple columns at once that run the same function. I have a list of column names and a function, there is a for loop that should iterate through the ...
Gregory C's user avatar
  • 495
1 vote
1 answer
102 views

Asking user to select any features in QGIS

I would be like writing a script on the PyQGIS console, that, at the beginning, stops itself and asks the user to select some features of a layer. I mean a window dialog which asks the user to select ...
Salvatore Diolosà's user avatar
0 votes
2 answers
49 views

QGIS not finding all layers?

I'm having an issue with QGIS not identifying all layers correctly. In my project, I have a group named "Mapas" with the following structure: Layers inside "Mapas": localizacao_pl ...
Geraldo PMJ's user avatar
0 votes
0 answers
45 views

What are the properties creating a new QgsSimpleFillSymbolLayer?

I would be create a new QgsSimpleFillSymbolLayer, setting also the shape of symbol. At the moment, I set just the color and the outline. layer_style = {} layer_style['color'] = '%d, %d, %d' % (...
Salvatore Diolosà's user avatar
0 votes
0 answers
44 views

How to handle dynamically created buttons and their functionality at QGIS Plug-ins

I am making my first plug-in and I created a plug in with the plug-in builder. As far as I understand, and please correct me if I am wrong, the plug_in_dialog.py script should handle all the dialog ...
mkr's user avatar
  • 11
3 votes
1 answer
98 views

Symbology display issues in raster layers

The code below aims to apply symbology based on NDVI values ​​to the selected raster layer. However, after running the script it does not display correct information (image 1). I need to access layer ...
geofausto's user avatar
  • 797
2 votes
1 answer
86 views

Changing frame styles of annotation with PyQGIS, e.g. setting the transparency to 0 %

With PyQGIS I want to create an Annotation, for each feature in a Layer. For that I wrote this script (with the help from Programmatically adding annotations and changing some points): from PyQt5....
Tim's user avatar
  • 325
1 vote
2 answers
155 views

Easiest way for non-programmers to add my script to QGIS

QGIS 3.36.2, Python 3.12.3 I've got a script (about 500 lines of code) that I add to my project and test with the "Open Existing Script" button of the Processing Toolbar (it's not formatted ...
Neph's user avatar
  • 291
0 votes
0 answers
50 views

How to render the features in according with a specific attribute

I'm writing a script on PyQGIS. My goal is to render the features of two layers in according with attribute "NId" that is the same for both layers "terrFiltrati" and "...
Salvatore Diolosà's user avatar
0 votes
0 answers
55 views

Calculating of point stationing along axis in QGIS

I have this issue in QGIS: I need to calculate the stationing of start- and endpoints from line features (cable management system) alongside an axis (railway). The stationing should run along the axis ...
Martin's user avatar
  • 23
0 votes
1 answer
61 views

QGIS plugin upload error: There were errors reading plugin package (please check also your plugin's metadata). Cannot find LICENSE in the plugin

My metadata text includes license=https://www.gnu.org/licenses/gpl-3.0.html and I have also included a license.txt file with the text of the license in the link above but still getting this error ...
rao's user avatar
  • 353
0 votes
1 answer
51 views

QGIS 3 Python script don't iterate through raster layers in print composer and saves only one raster layer with different years

I use QGIS3 and I have project with series of heatmap raster layers from different years (Grass_Snake_2005-2024, one raster layer for each year), in this project I set up already map in map Print ...
Lukasz Ponienski's user avatar
0 votes
1 answer
47 views

QGIS crashes when I set the labels

I'm writing a script for QGIS, using the Python console. I noticed that when the script processes the rows about the label settings, when I delete the layer "terrFiltrati", QGIS crashes and ...
Salvatore Diolosà's user avatar
3 votes
1 answer
85 views

Getting signal on layer scale based visibility changed in PyQGIS

Is it possible, to get a signal, when something (user or script) changes layer scale visibility? I tried layer.configChanged.connect(self.test_2) layer.flagsChanged.connect(self.test_2) layer....
Dezmonder's user avatar
  • 299
0 votes
0 answers
56 views

QGIS crashes when the script runs

I'm writing a script on PyQGIS, but when I start it, this always crashes and I don't understand the reason. After a lot of attempts, I undersand the problems are the following rows of code: QgsProject....
Salvatore Diolosà's user avatar
0 votes
1 answer
57 views

Running script converted from PyQtDesigner on PyQGIS

I converted a .ui file of a project built on PyQtDesigner into a file .py. In an external IDE, the code works and the dialog window shows, while on the Python console in Qgis doesn't work. Here is the ...
Salvatore Diolosà's user avatar
0 votes
2 answers
91 views

How to import other scripts in the same folder?

I'm writing a PyQGIS script and I would import in my script other external scripts. I tried in this way but the code doesn't work. from PyQt5.QtGui import * from PyQt5.QtCore import * import ...
Salvatore Diolosà's user avatar
3 votes
1 answer
75 views

"Enable" custom icon to give it QGIS' default white border

QGIS 3.36.2, Python 3.12.3 If you hover over an icon of the default toolbars in QGIS (e.g. the Toolbox), then that icon gets a light grey background and a black border (leftmost) until you move your ...
Neph's user avatar
  • 291