Questions tagged [pyqgis]

Python bindings for QGIS.

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

Reprojecting QGIS vector layers problem

Using QGIS 3.8.0. Despite similar questions out there I can't reproject a vector layer to a geopackage while specifying the original table name in a qgis python processing script. FYI all tablenames ...
1
vote
0answers
36 views

Comparing between layers name and merging layers having same name using PyQGIS?

I'm trying to write python script in QGIS to merge layers having the same name. To do that I specify the name of layer in the script, so all layers having this name, will be merged. However, since ...
0
votes
0answers
25 views

Using QGIS with system Python?

I'm trying to use the pyrealsense library from Intel in QGIS in Win10 The current version of mine is QGIS 3.4, which comes with Python 3.7 But the pyrealsense supports pip install on 3.6 and 2.7 I ...
2
votes
0answers
25 views

How to fix the error '_core.QgsProcessingException: There were errors executing the algorithm.'

I am trying to get the overlapping features between two layers in a loop. This works fine in most cases but raises an exception in some cases. The exception traceback does not even give any hint what ...
2
votes
0answers
21 views

QGIS3 python: right(QTextStream) - getting unexpected type ' str'

I have a field type double that I need to reduce from 9 digits to 8 ie 123456789 -> 23456789. If I do it as an integer I loose leading zeros ie 10002345 -> 2345. I am attempting to use refactor fields ...
0
votes
0answers
22 views

Executing script in QGIS after complete load?

I'm looking for a solution to run a Python script after the complete load of QGIS. The startup.py is executed during (or before) complete load, so it doesn't work well. I would like to trigger the ...
0
votes
0answers
19 views

Exporting coordinates to CSV with 2 decimals using PyQGIS?

I want to export a point-layer to a CSV using a plugin I am working on. Amongst other attributes, the coordinates are exported via layerOptions=['GEOMETRY=AS_XY']. Everything is working fine, however, ...
0
votes
1answer
38 views

Symbolize the selected feature

I am working on a plugin on QGis, i want to know if it possible to change the color of the border of the selected polygone, to appare differently from other polygones when i print the layout. Cordialy
1
vote
1answer
29 views

Polygon from QgsPoints - QGIS 3.8 python

I'm trying to create a polygon layer from 4 points that I have already defined. There issue here is that I'm always getting the following error: AttributeError: type object 'QgsGeometry' has no ...
0
votes
0answers
17 views

Method to change values in raster with certain conditions in Python (QGIS)

I'm creating a plugin which changes the temperature on a map based on a new land use value. For this I created a Dataframe with these temperature changes. For the indexes of the rows I have a raster ...
1
vote
0answers
18 views

Script PyQGIS without Interface in Ubuntu

please can you help me? I tried many times to do a script of pyqgis but without interface qgis. I use QGIS 3.6.3 and Ubuntu 18.04, does Somebody know do this?
1
vote
0answers
24 views

'python-qgis' is not recognized as an internal or external command, operable program or batch file

As per - https://root676.github.io/installation.html - I am trying to install QNEAT3 via the OSGeo4W shell using python-qgis -m pip install matplotlib, however I am getting the following error message:...
1
vote
1answer
19 views

Creating gradient-filled rectangle in PyQGIS layout?

I have created a print layout with some of the layers of my QGIS Project using PyQGIS. I am trying to add a gradient filled rectangle to the layout. In the GUI, I would use the "Add Shape" --> "Add ...
-1
votes
0answers
15 views

Making installer for MySQL and QGIS? [closed]

How can I make installer that is going to install in few clicks MySQL database that is filled with our data and QGIS 2.18 with plugin we made? We need it because we want to have portable application ...
1
vote
1answer
73 views
+100

Perform GDAL Tile Index Loop on list of PDF file paths

I am close to creating a vector extent/bounding box for each PDF exported from QGIS using PyQGIS. I'm using the algorithm 'Tile Index' to attempt imputing a list of file paths to PDFs. The code below ...
1
vote
1answer
72 views

Unexpected behavior of QGIS appears when I load a raster layer

I have a small plugin for QGis which is collecting paratemters from gui for URL request to load raster layes (WMS). Example: urlWithParams = self.get_values() mylayer = QgsRasterLayer(...
1
vote
0answers
28 views

Use of QGIS/GRASS/SAGA procedures on Geometry Generator

Im new at QGIS, started 2 weeks ago. I'm trying to automatize the display of a map and get rid of some "duplicated" layers and all the extra work. I need to know if SAGA's dissolve can be used in the ...
3
votes
0answers
36 views

Running Standalone PyQGIS Script with Multiprocessing?

Is it possible to run a standalone PyQGIS script using multiprocessing for better performance? I'm creating 1,800 rendered map images and would like to run it across 4 processes to speed it up. If I ...
2
votes
0answers
13 views

Preserving provider of original raster layer when it is modified for another resulting raster layer?

A while ago, I asked for a method to assign new QgsRasterBlock objects to a QgsRasterDataProvider objects at Assign new QgsRasterBlock object to a QgsRasterDataProvider object. The reason was for ...
2
votes
0answers
46 views

Spliting Curved Polygon with various length of lines using PyQGIS?

To split the curved polygon (river polygon) with various length of lines while keeping the original line position, I tried the procedure as bellow. extend the lines using 'qgis:extendlines' ...
-3
votes
0answers
78 views

Calculating graphical area of polygon using QGIS? [closed]

How can I get the graphical area of polygon witouth using coordinates with pyqgis? Manually we subdivise the polygone into many shapes(Triangles, rectangles..) and calculate area of every shape to get ...
1
vote
1answer
48 views

Get junctions from pipeline in QGIS

I have pipeline network by shapefile, I want to get junctions and it must have link with pipes to run Epanet (id's junctions must have in node1 and node2 of pipeline). I know that we can extract point ...
3
votes
1answer
64 views
+50

Improve performance of Aggregate process from FieldCalc by using PyQGIS 3

I have a aggregate process that takes about 9h to run collecting data from a point dataset to put into a line. The process is aggregate(layer:='Roads_10m_Chainage.tab', aggregate:='max', expression:=...
2
votes
1answer
33 views

Creating standalone application in QGIS

I'm new to GIS but I've already a signifiant experience in development. I work on new project. We're trying to use the power of Qgis to create a GIS tool for our commercial team. QGis is istalled ...
2
votes
0answers
49 views

Calculating distance of individual points along line in PyQGIS? [closed]

I have a vector layer and need the distance between the points. This is an intermediate step for my further calculation and programming with Python. The starting point is stored in another layer (...
2
votes
0answers
29 views

Standalone PyQGIS file lock

I have a simple script for processing thousands of rasters/shapefiles. i am not able to delete temporary files, which are created by processing. I can pass them to: 'memory:output_file' but not for ...
1
vote
0answers
44 views

RuntimeError occurs randomly on pyqgis loop

I wrotee a loop in pyqgis 3 to apply processing to each polygon of a layer. Apparently randomly, a RuntimeError occurs and crashes my script. Here is the loop part of my script, with the first ...
4
votes
1answer
36 views

Understanding QgsRasterBlock size using PyQGIS?

I'm making a QGIS 3 processing algorithm to perform an unsupervised classification with K-Means. When I'm reading the image bands I realized that the following code only works when the image's pixel ...
3
votes
2answers
104 views

PyQGIS: Extract Vector Extents of PDFs Derived from QGIS 3.0

I'm interested to create a vector point layer representing the centroid of some 500-1000 PDF files exported from QGIS to find PDFs geographically rather than using file explorer. I would like to ...
2
votes
0answers
36 views

When does a Python script in QGIS execute drawing of QgsRubberBand?

I have a script which has an unrelated error after the draw_polygon function. I don't care about the error at the moment because I want to see the current results. For some reason my draw function ...
1
vote
1answer
46 views

Aligning rasters with Python (QGIS)

Does someone know if there is a SAGA or GDAL tool that is capable of aligning two raster layers? For the creation of a plugin I want to automate this process so the raster alignment option of QGIS ...
2
votes
1answer
31 views

Writing log message in QGIS's script algorithms GUI tab for PyQGIS 3?

I want to write some log in the log tab of processing algorithm User Interface like this post but for QGIS 3 (PyQGIS 3). It seems that "progress.setText('Youpi')" does not work anymore. What's the ...
2
votes
1answer
71 views

Getting the 'memory:' layers after grass7:v.clean processing using PyQGIS?

To repair geometries errors, I'm now trying processing (grass7) using PyQGIS. For one polygon layer (QgsVectorLayer: 'hn_pg'), I wrote the below script and run the grass7:v.clean algorithm. The ...
2
votes
0answers
25 views

Drawing ellipses over a tile map server in PyQGIS?

I have a few ellipses, defined by a latitude, longitude, semi-major axis in nautical miles, semi-minor axis in nautical miles, and an orientation. I'm trying to render them over a Google Maps layer. ...
1
vote
1answer
50 views

Running standalone QGIS model script in Python?

I am trying run an exported QGIS model as Python script from anaconda. I followed Executing a standalone QGIS python script on Windows 10, and I get no error of modules, when running this I get no ...
1
vote
1answer
28 views

Extra [ ] in layer QGIS Python Console

I'm trying to write a "simple" plugin as training and to automate a task repetitive task as well. I would like to have the map layer hardcoded instead of make sure you select the correct one but if I ...
1
vote
0answers
37 views

Loading PyQt5 modules from QGIS3/PyQGIS

I am trying to talk to the PyQGIS API for use in a 3rd party application using the offical .dmg image provided on the QGIS homepage. After setting PYTHONPATH to /Applications/QGIS3.4.app/Contents/...
2
votes
1answer
37 views

QGIS Python, adding attributes and populating the fields

I am writing a script to add attributes and then populate the fields. When I run the script in QGIS in the python console, it works. But when I put it in a script and run it through a plugin, it only ...
1
vote
1answer
43 views

Reading label settings with PyQGIS in QGIS 3?

I am struggling to read (with PyQGIS) even the most basic settings from a labeled shapefile in QGIS 3. I know this was pretty easy in QGIS 2 with .readFromLayer but it does not seem to work in QGIS 3. ...
4
votes
1answer
45 views

PyQGIS Problem adding certain vector layers to QGIS from postgres

I've created a tool to find layers from our PostGIS database based on a string match and add them to the current QGIS project. In the example below I'm searching for 'landscape' in the dataset name. ...
3
votes
1answer
31 views

Custom function in expression editor

I am trying to make a custom function in the QGIS expression editor that takes three arguments. Below is the tested standalone function, which I would like to integrate: import math def qfull_circle(...
1
vote
0answers
30 views

Loading offline tiles as QgsRasterLayer in C++ or Python?

I have created tiles via Qtiles plugin in QGIS. Here is the code snippet I have so far: QString url = "file:///C:/Users/USER/Desktop/TiledMap/{z}/{x}/{y}.png"; QgsRasterLayer * lyr = new ...
2
votes
1answer
31 views

ImportError when trying to load otb (orfeo-toolbox) into QGIS Python Console

I would like to use the orfeo-toolbox via the QGIS Python Console, however, I don't seem to be able to import the otbApplication. I keep getting the following error: import otbApplication Traceback (...
2
votes
1answer
60 views

Additional No Data Value Raster Pyqgis 3

I would like to improve way to adjust histogram of Sentinel 2 images in Qgis 3. I am using pyqgis to do the first task to it (create histogram rightly). So I have images that 0 is a no data value. To ...
2
votes
1answer
43 views

Clip overlap from polygons

I am trying to script the clipping of overlapping areas from a set of polygons. After having fetched features (outerFeature) a loop (innerFeature) is to check if other features intersect with area > 0....
2
votes
1answer
61 views

Copying and pasting features using PyQGIS?

I have created a table join between two shapefiles which I've named 'OSMM' and 'Mastermap'. I want to copy and paste all features (polygons) without a match from the target layer (Mastermap) into the ...
2
votes
0answers
49 views

Loading multiple CSV in QGIS? [closed]

I tried to use the same coding from Loading Multiple CSV Files into QGIS 2.10 to load multiples CSV in QGIS but in QGIS 3.6 and it does not work. The code provided in the above link was used and the ...
2
votes
1answer
44 views

Reading label positions from attribute fields with Python in QGIS 3?

I'm trying to label a shapefile with coordinates from attribute table with pyqgis. I've been messing around with labeling shapefiles with python, I can do most things that I need, but the main ...
1
vote
0answers
36 views

Refreshing only part of QgsMapCanvas? [closed]

When using the refresh() function, is it possible to only refresh part of the map canvas, instead of refreshing all of it? I am using C++ but can use any code snippet even if it is in Python.
1
vote
1answer
86 views

Query in QGIS is significantly slower, than in pgAdmin

So, I've a table in postgresql, that is joined to other spatial table. If I've run a simple query in pgAdmin, let's say SELECT * FROM table1 WHERE "area" > '5000' and it takes less, than 1s to ...