Skip to main content

Questions tagged [pyqgis]

Python bindings for QGIS.

Filter by
Sorted by
Tagged with
0 votes
0 answers
9 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
16 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
  • 1
0 votes
0 answers
6 views

How to load the last generated temporary GRB file into QGIS

A modulator generates outputs, one of them appears in the log. .... p: C:\Users\p\AppData\Local\Temp\processing_XlaQIL\f9b4c6a903984db787296bee038e79b3\CRAYFISH_OUTPUT_GRIB.grb... A .grb file is ...
fcka's user avatar
  • 985
2 votes
1 answer
50 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
  • 323
0 votes
2 answers
80 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
  • 269
0 votes
0 answers
36 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
40 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
20 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
45 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
31 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
51 views

Get 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
-1 votes
0 answers
42 views

'ImportError: attempted relative import with no known parent package' when QGIS-Plugin code running in PyCharm

I have created a 'raw' plugin with the pluginbuilder. The structure is as follows: It runs perfectly when opened in QGIS. However, when I open the plugin-folder as a pycharm project and run the ...
i.i.k.'s user avatar
  • 1,753
0 votes
0 answers
34 views

QGIS crashes when the script runs [closed]

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
40 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
64 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
57 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
  • 269
0 votes
1 answer
50 views

Load results of split vector tool into group using PYQGIS

I try to write a script to automatically merge some input layers (all of the same structure) of a geopackage into one, afterwards split it by a specific attribute and save the output as geopackages to ...
Calidris's user avatar
0 votes
1 answer
80 views

Creating a 'group' or 'menu' in QGIS of multiple plugins

I will create a bundle of plugins (one is already created). Instead of storing each plugin loosely as a single plugin, I would like to have them stored in a group,smiliar to a a menu like this: How ...
i.i.k.'s user avatar
  • 1,753
0 votes
0 answers
27 views

MapTool in Processing Provider Plugin

I created a simple plugin using the Plugin Builder and placing the "Tool button with a dialog" option, however, as I added more things to the plugin, I saw the need to place it as a ...
Mestrexama's user avatar
0 votes
1 answer
44 views

Sublayer from a Geopackage file shows as geometrytype 0 (unknown), but it contains points. It doesn't show the points either. How do I fix this?

I have geopackage file that contains sublayers that containts points. I want to access the sublayer and create a new file of it. Despite the points it shows the geometry type as unknown. The points ...
user103858's user avatar
0 votes
1 answer
37 views

Optional argument has wrong value when used with action trigger

QGIS 3.36.2, Python 3.12.3 I've got a regular action that is part of a toolbar and that calls a function when pressed, which uses an optional argument with a default value: class MyClass: def ...
Neph's user avatar
  • 269
0 votes
0 answers
26 views

Reduce raster file size during QGIS Python script processing

I wrote a Python script based for QGIS that is using the raster calculator to create a new raster based on two existing raster inputs. My problem is, that each output file is 35 GiB and I do have not ...
ScienceNoob's user avatar
0 votes
1 answer
59 views

Creating QGIS projects with iteration using PyQGIS - Problem with the location of layers added

In the following PyQGIS script, I iterate through each shapefile in input_directory, where each file represents an individual prefecture. To manage project isolation and ensure clean operations, I ...
Ilias Machairas's user avatar
0 votes
1 answer
50 views

QGIS Python Get and layout item's Uuid

I am working on synchronising the view extents of maps on layouts. I can do this using .layoutByName, .itemById, .extent and then .setExtent to get the Map I want from the right layout then find its ...
Sethinacan's user avatar
  • 1,726
2 votes
1 answer
82 views

Custom panel is created but does not display properly in custom plug-in

I am using the answer to Adding custom panel to QGIS to add a custom panel to my existing custom QGIS plug-in. So far, the plug-in only uses modal dialogues. I try to show the widget from the callback ...
Nick's user avatar
  • 123
1 vote
1 answer
52 views

Deleting GeoPackage vector layers and releasing open file handles with PyQGIS

On Windows 11 I have a PyQGIS script that creates layers from gpkg files. This all works perfectly fine. I want to delete these layers, recreate the gpkg files and reload them as layers again and this ...
John_nz's user avatar
  • 41
1 vote
0 answers
55 views

Why PyQGIS is not calculating the square root correctly in this expression

I have a shapefile with ~100 fields, the first ~50 fields are motion towards the east, and the last ~50 are motion towards the north. There are 50 fields because each represents a date. I want to ...
Na_Na_Na's user avatar
  • 131
0 votes
1 answer
64 views

How to add OpenStreetMap layer as bottom layer via QGIS processing script

I want to add an OpenStreetMap layer as the bottom layer of my project via a script. This works from the console: project = QgsProject.instance() root = project.layerTreeRoot() all_layers = root....
Nick K9's user avatar
  • 185
3 votes
1 answer
110 views

Attach functions to QGIS processing algorithms

I am trying to find a way to attach a function to run whenever any processing algorithm either starts, succeeds or fails in the main QGIS application. The functions should be attached when a plugin is ...
Dror Bogin's user avatar
  • 3,555
0 votes
0 answers
53 views

How to keep attributes after a clipping operation in PyQGIS?

I'm trying to do a spatial clipping operation between 2 point layers, representing buildings and earthquakes, and a buffer area created by the user. The problem is that after operation, all attributes ...
Salvatore Diolosà's user avatar
1 vote
1 answer
44 views

Layers corrupted after saving, closing and opening of QGIS project with PyQGIS

Using a Python script, I create a layer from a CSV file and then write it out to a gpkg file. I then create a group in the layer tree, load it in the gpkg file and add it as a child of the group. This ...
John_nz's user avatar
  • 41
0 votes
0 answers
25 views

Stretch Singleband Pseudocolor with Cumulative Cut

I'd like to use the QGIS Python Console to stretch a raster layer that's already symbolized as Singleband Pseudocolor. I can push either button, , but I'd rather script it for a layer(s). The only ...
cndnflyr's user avatar
  • 3,412
0 votes
0 answers
27 views

Incorrect display of map themes

I have created layer styles and wanted to create specific map themes with another script. Unfortunately, the styles are not loading properly and the map themes are faulty and sometimes not selectable. ...
Energychange's user avatar
0 votes
1 answer
59 views

QGIS script keeps crashing

The following is the only the beginning of my script but this is where the problem is located. It runs fine the first time, but break the second time I try running it. I am running the script directly ...
Christiaan Goosen's user avatar
0 votes
0 answers
30 views

How to add a north arrow using stock QGIS images in Python

I am trying to add a north arrow to a map (QgsPrintLayout) using PyQGIS. The closest thing I could find is from this GIS.SE question (Adding north arrow using PyQGIS): north = QgsLayoutItemPicture(...
tinlyx's user avatar
  • 11.1k
0 votes
0 answers
26 views

Assigning a band name when using QgsRasterFileWriter/QgsRasterDataProvider

I want to write binary data to a new raster file using PyQGIS' QgsRasterFileWriter. Everything works fine but I would like to also assign a specific band name to the written raster band. How can I do ...
bugmenot123's user avatar
  • 10.9k
1 vote
0 answers
42 views

Adding data-driven command in PyQGIS

I want add to my code line which add option placed label based to data. I would use string in_mask(0) as string, because i want hide labels under the mask. layer = QgsProject().instance()....
szoon's user avatar
  • 111
0 votes
0 answers
32 views

QGIS/GDAL warp(reproject) throws 'ERROR 5: dfMax should be strictly greater than dfMin' when run in Python script

I have ~ 150 .xyz-files (DEMs) which I try to reproject. When I reproject them within QGIS via raster -- > warp everything works fine. First I tried the batch processing option with warp(reproject)...
i.i.k.'s user avatar
  • 1,753
0 votes
0 answers
45 views

Issue with Google Earth Engine Plugin in QGIS

I am trying to resolve an error from using the Python console on QGIS. I have QGIS version QGIS version 3.34.4-Prizren on my linux Ubuntu 22.04.4 LTS, Codename-Jammy. Then I successfully installed ...
TG_'s user avatar
  • 1
1 vote
0 answers
26 views

QGIS Snapping on invisible(by scale) features [closed]

I using QGIS 3.34 (but in 3.36 same problem). When I turn on snapping, it snaps to layers, which are invisible by scale. But it isn't snapping to features which are invisible by rules in style (and ...
Dezmonder's user avatar
0 votes
0 answers
37 views

Error when using vector layer merge tool in PyQGIS: 'incorrect parameter value for LAYERS

I am attempting to use the QGIS tool to merge vector layers and then load the merged layer temporarily in QGIS after running the following Python code. However, I am encountering an error message. ...
Raíssa Daher's user avatar
2 votes
1 answer
50 views

Deactivating the render checkbox of status bar with PyQGIS

I was wondering whether it is possible to activate/deactivate the Render function of the QGIS canvas: I searched everywhere online but I found nothing even about the function itself.
Kai's user avatar
  • 371
0 votes
0 answers
33 views

PyQGIS capture screen around mouse pointer

I'm developing a PyQGIS plugin, that shows different terrain details for the area hovered by the mouse pointer. I'd like to implement a screenshot feature that would allow the user to screenshot the ...
oliver's user avatar
  • 95
0 votes
1 answer
56 views

import module qgis.core in standalone script with pyqgis without running bat before with environment?

To run a python script (example file "standalone.py") with module qgis.core I have to use a specific bat file (that call the py file!) with the following environment! "rem Call ...
simone100's user avatar
  • 193
0 votes
1 answer
74 views

QgsRasterBandComboBox/ ComboBox unable to process raster calculator

I'm creating a plugin to calculate NDVI and NDWI indices in QGIS v3.36.2. I have successfully created the GUI as below and successfully loaded the layers and bands of the layers. The data I am using ...
ExHunter's user avatar
  • 101
0 votes
1 answer
59 views

How to use a python virtual environment on QGIS?

I'm currently developing a QGIS plugin and I want to use pydantic in this plugin. I'm currently using python 3.12 and QGIS 3.36. It is not recommended to install package in the python system ...
Jérémy O.'s user avatar
1 vote
1 answer
38 views

I can't update any attribute values in PyQGIS

I've been using PyQGIS for a few of weeks. I'd write a script which shows all earthshakes responding to given parameters, so I wrote this code: from PyQt5.QtGui import * from PyQt5.QtCore import ...
ytreka's user avatar
  • 11
2 votes
1 answer
79 views

TypeError when using QgsRasterFileWriter.writeRaster in PyQGIS

In the QGIS 3.36.1 Python Console, I'm trying to create an output raster so I can write pixel values sampled from another raster. output_raster_path = r'D:\Output Raster.tif' output_raster = ...
GlenS's user avatar
  • 566
0 votes
1 answer
77 views

QGIS Python console - if condition for NULL values

I'm new to Python. I have already made some programs with GeoPandas. It works very well but now I'd like to use the QGIS python console this time to do some simple operations that I can't do with QGIS ...
Jrôôm's user avatar
1 vote
1 answer
71 views

MultiPolygon to Polygon in Python [closed]

I need to change geotype from MultiPolygon to Polygon. Most of the original features are Polygon, but are automatically imported through API as MultiPolygon. How can I change all the types ...
Ilya's user avatar
  • 13

1
2 3 4 5
154