Questions tagged [pyqgis]

Python bindings for QGIS.

Filter by
Sorted by
Tagged with
0
votes
0answers
27 views

Why basemap appears blank in Standalone PyQGIS on Linux?

The script below processes Geotagged photos generates a shapefile of locations, plots them on a base map, exports the output to a png/jpg image. It is working fine within the QGIS environment or as a ...
1
vote
1answer
49 views

Getting all layer names from opened .qgz project file using PyQGIS

I have several .qgz project in different directories. I would like to get all the (displayed) layer names from each project. I tried several forms of code to get it from documentation, but it only ...
3
votes
1answer
74 views

Getting Intersect Feature in PyQGIS

I tried to get the intersect line feature if user placed point on that line. I tried below: class AddPoint(QgsMapToolEdit): def __init__(self, canvas, iface, Layer): self.canvas = canvas ...
7
votes
2answers
143 views

Highlighting snapping position in PyQGIS

I'm trying to add points on a line with QgsMapTool. I need to show snap indicator (vertex or edge) while moving the mouse on a line. How can I do that? Here is my code: class uubEditTool(...
4
votes
2answers
181 views

Batch renaming of columns in attribute table for shapefiles using QGIS

I have 11 shapefiles that shows administrative areas for 11 different countries. For each country, I have 448 columns in the attribute table that records average rainfall data. They look like this: I ...
0
votes
1answer
32 views

Using pyqtSignal in emitting signal for maptool in QGIS

For QGIS I have a plugin named GGAImporter: from .point_tool import PointTool class GGAImporter: ... def addFachdatum(self): self.mapTool = PointTool(self.iface.mapCanvas()) self....
0
votes
0answers
32 views

Displaying non processing QGIS plugin icon in processing toolbox

I am developing a QGIS processing plugin that has many algorithms. Apart from various processing algorithms, there is one tool that is non-processing. I would like to display them all together to the ...
2
votes
1answer
90 views

Loading another QGIS processing algorithm window from processing algorithm

QGIS Processing class has a method execAlgorithmDialog() that opens the dialogue window of any processing algorithm. I am writing a Plugin that has a processing algorithm Run Analysis, I also need to ...
0
votes
1answer
43 views

Finding rasters overlapping polygon shapefile

I have 10,000 rasters but I only need 1000 of them but do not know which 1000. The 1,000 I need to utilize overlap a vector polygon shapefile and another single raster I have (well the value of 1 in ...
2
votes
1answer
40 views

Getting point geometry by clicking at the map within QGIS plugin

From QGIS 3 Plugin Tutorial I need the example for getting a point geometry from clicking at the map. So I have a file point_tool.py: from qgis.gui import QgsMapTool, QgsMapToolEmitPoint from PyQt5....
1
vote
0answers
29 views

ModuleNotFoundError: No module named 'qgis' MacOS

trying to setup pycharm for QGIS development in MacOS. I added to the interpreter path the QGIS bin path /Applications/QGIS.app/Contents/MacOS/bin but still no luck. All the guides I find are for ...
1
vote
0answers
39 views

Looking for definitive way to enable ALL QGIS module access in VS Code (Windows 10)

I'm having trouble importing and getting code inspection/autocompletion working for all the PyQGIS modules I need to do scripting in VS Code. After looking at these questions: Understanding qgis....
2
votes
0answers
27 views

What is the difference between QGIS PostProcessorInterface and postProcessAlgorithm

QgsProcessingLayerPostProcessorInterface.postProcessLayer() vs QgsProcessingAlgorithm.postProcessAlgorithm() They both seem to post-process a layer like style it or change its display name. What are ...
2
votes
1answer
76 views

Feed an existing raster to QGIS Raster Destination Parameter in QGIS Processing Algorithm

I am writing a QGIS python script. In the script, I am using QgsProcessingParameterRasterDestination class to ask the user where do they want to save the output raster. For any other QGIS processing ...
2
votes
1answer
101 views

Dynamic height value from a layoutItem using a PyQGIS function in QGIS

I'm trying to make a function that allows me to get the dynamic height of a LayoutItem in the print composer. I'm working in QGIS 3.16. The following code works well to get an item height, when I run ...
1
vote
1answer
34 views

Connecting layout text boxes to item before it in QGIS 3

I have an atlas layout in QGIS 3.16 where input data can vary in character length. Therefore I made a override of box height based on text length. The problem I ran into, is that if the text is longer ...
0
votes
1answer
46 views

QTableWidget hoizontalHeaderItem is returning None

I am developing a tool is Qgis3 using PyQt5. I am adding columns using a button and the setting column names using 'setHorizontalHeaderItem'. But it gives None while trying to read it. Following is ...
1
vote
1answer
82 views

Adding output layers of QGIS processing scripts to group using PyQGIS

I have a QGIS python processing scripts that return multiple rasters. I want to return them in a group named 'Aligned'. There is nothing in the context.addLayerToLoadOnCompletion() function to specify ...
1
vote
0answers
17 views

Pushing Symbology and Labeling from Layer Properties in QGIS to features on Map and TOC with Python

I'm using QGIS 3.20.3-Odense. I have written a script that changes the symbology and labeling of layers in QGIS. Everything looks great when I double click on layers in the TOC to view the Symbology ...
0
votes
0answers
31 views

Forcing point inside of polygon using QGIS with Python [duplicate]

How do I check the "Force point inside polygon" box found in the Labels -> Placement tab for polygon layers using Python?
0
votes
0answers
73 views

Internationalization of QGIS processing scripts

How can one translate QGIS processing scripts GUI and user messages to other languages ? The QGIS documentation explains how to translate Python plugins, but not processing scripts.
3
votes
1answer
68 views

QGIS crashes when creating many features through plugin

I have a plugin, built with plugin builder 3.2.1. I'm running it in the current long-term release of QGIS, 3.16.13 using its built in version of Python 3.7. Within the run method, I call a second ...
0
votes
0answers
40 views

PyQGIS MS SQL table with two geometry columns

I have a Mircosoft SQL Server database. In a table I need to save two different geometries in a same record (row). Is for this I create two columns. The second one I created adding a column using MS ...
0
votes
1answer
36 views

Importing vector grid of a country from QGIS in python [closed]

I created a vector grid over a certain country (EPSG:4326) with a size of 20kmx20km (spacing) in QGIS. I want to work with this layer using Python with below goals: I have pairwise locations in a ...
1
vote
0answers
61 views

QGIS says Python is not supported and cannot access plugins or console

Following the recent PSA recommending users to upgrade from 3.16.12 to 3.16.13 (link), I've been having trouble accessing my plugins and Python console ever since upgrading. I've done some digging and ...
1
vote
1answer
45 views

Creating percentile class breaks in vector data QGIS using numpy.percentile

I am having trouble making percentile breaks in my point data for a numeric field. I have looked at these similar questions, most seem to relate to raster though: Exporting features when column value ...
2
votes
1answer
93 views

It does not render the project layers in the Qgis canvas nor in the Layout exported as pdf

I'm writing a standalone script where I create a project, load layers, style them, call another scritp (.py) with functions to add a layer to the OpenStreetMap background and set the layout to export. ...
2
votes
1answer
86 views

Using "Select by expression" in processing script context with PyQGIS

Is there a way to select features and use them in subsequent algorithms within a processing script context? I am looking to iteratively selectbyexpression a subset of line features in a layer based on ...
3
votes
1answer
70 views

Changing output layer's name in QGIS processing plugin

I am writing a plugin to convert degree to DMS format. I want to name the output layer containing name of source layer. For example source layer name 'Polygons_WGS84', output layer '...
1
vote
1answer
51 views

QgsProcessingParameters Checkable Combo Box option?

Is there a simple method in the QgsProcessingParameters class for a checkable combo box option? I cant seem to find the function described in the offical documentation or figured out any alternative. ...
2
votes
0answers
85 views

Error: Algorithm not found using grassprovider in PyQGIS standalone script

With QGIS 3.22 the GRASS algorithms got its own provider (grassprovider.Grass7AlgorithmProvider) and are no more part of processing.algs. Knowing this, in a standalone pyqgis-script I am trying to add ...
1
vote
0answers
22 views

Processing raster changes pixel value from 255 to 0

I have a raster which I need to clip with a polygon using PyQGIS. So far it works fine, but now I came across some special cases in my source rasters where my script shows behaviour I do not ...
0
votes
0answers
53 views

Performance in reading and writing rasters using Python and GDAL

I've been thinking about how to improve my plugin's performance, which involves a lot of operations in chain (always getting the result of the previous algorithm). One of the problems I noticed is ...
1
vote
1answer
77 views

Deleting created custom CRS using PyQGIS

How can I delete custom CRS by PyQGIS? My not working solution is: my_crs = QgsCoordinateReferenceSystem() my_crs.createFromProj4("+proj=aea +lat_1=21 +lat_2=49 +lat_0=37 +lon_0=87 +x_0=0 +y_0=0 +...
0
votes
1answer
50 views

Raster ColorBand Classification in PyQGIS

I would like to define the style of a DEM using Color Band Classification: Interpolation : linear number of class: 5 blending mode: Multiply color palet : reverse pallet spectral At the moment, I ...
1
vote
1answer
127 views

RuntimeError: qgis._gui cannot import type '����' from PyQt5.QtCore

I am writing a standalone script in atom to create a new project and load a layer. The problem is that I wanna use the next command: vlayer = iface.addVectorLayer('', '', '') To load layers, then, I ...
2
votes
1answer
71 views

QGIS Raster Calculator using Python to combine two layers

I am a QGIS beginner and I want to combine two layers using the raster calculator via Python. For the beginning, I simply want to add the two layers but currently, I don't get an output file. Code is ...
1
vote
0answers
100 views

QGIS Processing Plugin works but opens new QGIS with critical warnings

I've developed a QGIS Processing plugin that takes an input of tweet IDs, gets their metadata and then extracts their coordinates to plot points. It works but it also causes a new QGIS window to open ...
2
votes
2answers
66 views

Getting schema names from PostGIS database in PyQGIS

I would like to list the names of all schemas of PostGIS in a given DB called DB-1 in PyQGIS. My attempt was inspired by : Getting table names from PostGIS database in PyQGIS from PyQt5.QtSql import * ...
0
votes
0answers
19 views

QGIS 3.16.6 AttributeError in script used to join three tables in PostgreSQL database

I am trying to get a PyQGIS script running that's joining a polygon and two tables in QGIS 3.16.6. Using the script, the user has to select several inputs from layers in the Layers panel that are ...
5
votes
2answers
102 views

Getting table names from PostGIS database in PyQGIS

I would like to list the name of all tables of PostGIS in a given DB called DB-1 in PyQGIS. I found this Q&A at Stack Oveflow: https://stackoverflow.com/questions/34418667/get-table-names-from-...
0
votes
1answer
56 views

Getting access to item properties of an overview from Layout Designer using QGIS

I try to establish an automated process for atlas printing. However, I am not able to get access to the drawing properties of the overview map of my layout. I want to have set the frame style of the ...
2
votes
1answer
43 views

Retrieving PostGIS selected table in PyQGIS

I would like to use the layer selected into the explorer's windows. My aim is to launch script using the name of the PostGIS layer selecter in this windows. Is it possible to retrieve the table ...
4
votes
1answer
76 views

Deleting QGIS project stored in PostgreSQL using PyQGIS

I would like to delete a .qgs project stored in PostgreSQL using PyQGIS. This SQL code does the job into pgAdmin : DELETE FROM test2.qgis_projects WHERE name = 'Project_name'; My attempt which doesn'...
3
votes
1answer
128 views

Clone PostGIS table in PyQGIS

I would like to clone a schema of PostGIS into the same database using PyQGIS. At the moment, I'm able to do it using SQL using pgAdmin with this code: CREATE OR REPLACE FUNCTION clone_schema(...
-1
votes
1answer
24 views

Toggle "PreviewAtlas" with PyQGIS

I am working on a plugin which should generate various atlas views based on some parameter. After choosing some variables, the LayoutDesigner should be opened with all the predefined options - this ...
0
votes
0answers
32 views

MODIS Land Surface Temperature hdf to tiff - problem with lst values after reprojection

I have a folder with MODIS/Terra Land Surface Temperature/Emissivity Daily L3 Global 1km SIN Grid V061 hdf files (downloaded from NASA's Earth Data Search). I want to use the following script that I ...
3
votes
1answer
105 views

How to extract "derived" attribute values in QGIS (using PyQGIS) into the attribute table?

I know how to extract the geometry data, but I am struggling with the following derived attribute data in QGIS: Searched a lot for extracting derived data, but only geometry data comes up. Result: I ...
0
votes
1answer
33 views

QGIS plugin fails to read proxy credentials from authcfg

I'm developing a public python plugin for QGIS. To support QGIS proxy settings, I use Qt Network. The plugin sends HTTP requests via the QgsNetworkAccessManager's get/post/delete methods. To test ...
2
votes
1answer
82 views

Adding a custom legend to my layout using PyQGIS

I am creating a layout with two maps, several boxes, picture, ... The problem turn up when I add a legend where I modified the layers. For that I create a list with layers in my map, after that, I ...