Questions tagged [pyqgis]

Use for the python library that applies to the Qgis GIS program.

Python bindings for the Qgis GIS program. Example code and descriptions can be found at https://docs.qgis.org/3.10/en/docs/pyqgis_developer_cookbook/index.html

170 questions
4
votes
2 answers

Where do I find an overview of all python functions for QGIS

I'm making a plug-in for QGIS, using the python language. I've looked everywhere but I can't seem to find a good overview of all the QGIS functions there are usable in the python script. For example, let's say I selected a Polygon as a geometry. I…
3
votes
0 answers

pyQGIS Custom Contrast Enhancement Function

I'm trying to implement a custom contrast enhancement function that will allow me to enhance an active raster layer in QGIS without having to create a new raster file. I'm not trying to do a MinMaxEnhancement or use any of the other existing…
bgordon
  • 149
  • 2
  • 15
3
votes
1 answer

Using third party Python modules in QGIS

I developed a QGIS plugin that uses third party libraries. The current situation is that the user of the plugin, has to install some Python libs into QGIS, before he/she can use my plugin. Every time a new QGIS version is installed, the used needs…
nlrmcm
  • 31
  • 2
2
votes
1 answer

An undefined letter appears?

I'm running the following snippet. For some reason, which I don't get, a "b" appears in the path when stating the location of a file. # %% Definitions path_root = normpath(r'G:\\Dropbox\\temp\\') path_start =…
2
votes
0 answers

QGIS-Pycharm-QT Reference not found

I know it is a never ending story and there a lot of articles around and I tried a lot of the tips without no success. Maybe I should also mention, that I had a lot of different versions of QGIS installed. The last one which was functioning in…
The Rabbit
  • 141
  • 5
2
votes
0 answers

Standalone PyQGIS: How to add new layer to map on runtime?

I can’t do setLayers(), for a layer created by QGIS processing algorithm on runtime. How to add new layers to QgsMapCanvas in standalone PyQGIS?
2
votes
1 answer

Disconnect signals for QGis plugin with dialog created by Qt Designer

I'm working on a plugin for QGis 3.x. The UI was created with Qt Designer and the plugin code boilerplate by Plugin builder. I do have 3 main files in my project : my_plugin.py with the main MyPlugin class and initGui(), unload() and run()…
Beinje
  • 572
  • 3
  • 18
2
votes
1 answer

How to add PostGIS SQL SELECT query as layer to QGIS 3 project using Python console?

I want to add a PostGIS SELECT query as a new layer to a QGIS 3 project using the Python console. It is a simple process to do this using the SQL Window in the DB Manager of QGIS. Here you can create a layer from any SQL query of a PostGIS enabled…
2
votes
1 answer

How to use multiple windows in Python Plugin

I wrote a plugin in PyQGIS, which contains several Ui's (using QT Designer). When I run the code in the QGIS Python console, it works wonderfully. Now I would like to make it available internally for the company as a classic QGIS plugin (start in…
cc_schr_gis
  • 123
  • 3
2
votes
1 answer

Finding directory of Python script from QGIS Python Console

I will be importing some CSV files from the directory of the script that I have opened on Python Console on QGIS. Yet, I cannot access the true directory with os.getcwd() or something else. Is there a way to do that?
meteergen
  • 121
  • 5
2
votes
1 answer

How to append / add layers to geopackages in PyQGIS

For a project I am creating different layers which should all be written into one geopackage. I am using QGIS 3.16.1 and the Python console inside QGIS which runs on Python 3.7 I tried many things but cannot figure out how to do this. This is what I…
M Geo
  • 25
  • 4
2
votes
1 answer

PyQGIS Features lacking geometry

I am working with a shapefile in QGIS (point layer),and I am trying to loop over all the points, however some are apparently not having a valid geometry. When I type layer.getFeature(1).geometry() I get And therefore I cant use…
Pawel
  • 39
  • 1
2
votes
1 answer

Editing layer via Python script startEditing, do we have to "close" editing?

I'm working on a vector layer where I have to merge all n+i [id] attributes into entity(n)[id] where entities(n+i)[id] equals the entity(n)[id], then delete all n+i entities. All works fine but I call several times startEditing functions before…
2
votes
1 answer

How to remove all layers *except* some specific ones in pyqgis?

I need to load several vector layers for my QGIS project, so that I test every function of my script in every one of them. However, in the end I want to work only with one or two layers of interest and discard the others, so I would like to do that…
1
vote
0 answers

QGIS PrintLayout: How to copy layout's items from one template to another using Python and export to PDF without losing map focus?

I'm trying to create a qgis plugin in python. And I have a problem with coping layout's items from one printlayout template to another printlayout template. When I execute this code: composition.loadFromTemplate(doc, QgsReadWriteContext(),…
Max
  • 11
  • 2
1
2 3
11 12