Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [pyqgis-3]

Python bindings for QGIS 3.

0
votes
1answer
10 views

PyQGIS - Add items to print layout

I have created a blank print layout, now I want to add items to it like a map, legend, etc. Here is my code so far to create a new print layout, this works just fine: #This creates a new print ...
1
vote
1answer
22 views

Looping through folders and select shapefiles by name using pyqgis

I want to loop through folders and find shapefiles which contains the name "GST" and merging them together using python in QGIS 3.4.3. In detail: The folder x contains four folders called VA72, ...
3
votes
2answers
63 views

Script I made for pyQgis runs slow but can't find another way around it

registry = QgsProject.instance() first_layer = registry.mapLayersByName('buffered')[0] second_layer = registry.mapLayersByName('buffered')[0] areas = [] instrument_number = "tin_ttl_in" proprietor =...
1
vote
1answer
39 views

Method asPoint().x() doesn't work in QGIS 3.4.3 but did in 3.4.1

I have built a plugin which does essentially this equal sized polygons along line Main parts of the code are from user lejedi76 I have used this plugin for months now and it worked as expected. ...
0
votes
0answers
8 views

Getting correct intersection length between two polygons using PyQGIS? [on hold]

I am asking a question based on this answer to Finding intersection length between two polygons using PyQGIS?. It is said in the latter part that between two polygons the intersection can of various ...
2
votes
1answer
28 views

PyQGIS QgsVectorLayer() Loads Invalid Layer in Standalone Python 3 Script

In my standalone python script, QgsVectorLayer() is loading an invalid layer. When I use the exact same function and inputs in the QGIS GUI python console, the layer loads fine. I am not sure what is ...
1
vote
0answers
23 views

Opening template project with PyQGIS in QGIS 3?

What do I need to do to open a project-file as a template with PyQGIS in QGIS 3? I am able to open a project like this: project = QgsProject.instance() project.read('C:/path/to/my/project.qgs') But ...
3
votes
1answer
72 views

Install QGIS plugin manually - Package not available in Plugin Manager

If it is helpful, I am using QGIS 3.4.3 (Madeira) and MacOS High Sierra v10.13.6 I am trying to install a QGIS plugin manually, I've been using the instructions from the PyQGIS Programmer's Guide by ...
1
vote
1answer
32 views

Writing pyQGIS 3 script to modify layer (add field and feel it) inside QGIS?

I have the following PyQGIS script with QGIS 3 that tries to ask for a layer, add a new field in that layer and modify the value of this field. But the code doesn't work. I get either Seems there is ...
2
votes
1answer
31 views

Finding polygon self-intersection with PyQGIS on QGIS 3.4

My script: from qgis.core import * import qgis.utils import processing, os, sys, glob polys = QgsVectorLayer("/Users/john/shapefile/layer.shp","intersection","ogr") output = "/Users/john/shapefile/...
1
vote
1answer
39 views

Create Widgets for specific fields of a feature

I need to create a widget were some fields of a feature are listed and are editable. I used QgsAttributeForm for this, but this widget is too big and has to many fields. I need to provide a ...
1
vote
1answer
35 views

Understanding QgsLayoutItemLegend of PyQGIS?

As I get more into QGIS scripting, I refer to the documentation often and usually without success. I have trouble deciphering how to interpret the classes, etc. I found this thread which is really ...
1
vote
0answers
20 views

QGIS 3.x closestSegmentWithContext returns sqrt distance 0.0 and point doesn't snap to polyline

I have a point and line shapefile. I am new to QGIS and Python, but have been able to get a working method to snap some of the points to the line. The method I am using is "closestSegmentWithContext",...
3
votes
0answers
39 views

Updating Algorithm list in pyqgis3?

I am attempting to run a union operation in a standalone pyqgis script and I'm receiving this error: Algorithm qgis:union not found The union operation fails with this code: params = { 'INPUT' ...
1
vote
0answers
14 views

Match a custom CRS to existing (proj4 database) ones in QGIS 3

I am reading SPS files (see format definition here) from which I gather CRS information. Unfortunately, there is no ESPG reference available nor is there any standard naming scheme for Ellipsoids so ...
2
votes
1answer
38 views

Launch Processing tool UI in pyqgis

This is a duplicate of Launching Processing tool User Interface using PyQGIS. However, the answer provided is not correct for QGIS 3.4.1. from processing.gui.CommanderWindow import CommanderWindow ...
2
votes
0answers
28 views

Does any body knows if there are a ArcSDM version or port for QGIS?

ArcSDM is a series of python analysis tools for ArcGIS developed by Don Sawatzky, Gary Raines y Graeme Boham-Carter in 2010. At present is maitained by the University of Campinhas, Brazil and ...
2
votes
0answers
38 views

PyQGIS - remove layer from legend

I'm creating a simple print layout with Python. I've created a legend but I want to remove a few items from it. Here is my code to create a blank Print Layout called "LayoutWithLegend" and add a ...
2
votes
0answers
32 views

QGIS 3.4 Processing Python Scripts folder default configuration is lost

I have lost the default configuration of the 'Processing Python Scripts folder' on QGIS 3.4 and in consecuence some Python processing scripts and plugins cannot work properly because they cannot find ...
3
votes
0answers
56 views

How to read PyQGIS documentation? [closed]

As I get more into QGIS scripting, I refer to the documentation often and usually without success. I have trouble deciphering how to interpret the classes, etc. I've been really struggling to create ...
2
votes
0answers
37 views

Is there a way in PyQgis to perform a transaction upon several features at once for undo and redo operations?

I'm developing a standalone application in pyqgis (python 3.6, qgis 3.2) for editing roads and ran into a problem connected to performing transactions. When the user of the app insert, update or ...
0
votes
1answer
29 views

How to get the Z values of existing lineStringZ with pyqgis?

I can get the values of 3D QgsPoints with mypoint.get().z() When I iterate through a layer to get a specific polyline and then iterate through the polyline to get the start and end points- start_point ...
1
vote
1answer
23 views

Getting Layer Properties of QGIS on standalone appliction using PyQGIS API

I am using PyQGIS API for developing the standalone application to load the certain VectorLayers. I used the QgsMapCanvas to load the map and QgsLayerTreeView to show the layer tree view using code ...
4
votes
1answer
64 views

pyqgis - post-processing of layer output of QgsProcessingAlgorithm

While extending a plugin with a Processing Provider and a set of algorithms I mostly followed the defaults of Plugin Builder 3. So, the basic code is smth along the lines of class ORSisochronesAlgo(...
2
votes
1answer
50 views

QGIS3.4 Madeira crashes when calling print()

I am using the pyqgis template from underdark for showing the crash. Her script is running like a charm, but as soon as I add a print("finished...")-call in her code, QGIS3.4 Madeira crashes. You can ...
2
votes
1answer
89 views

Getting line geometry out of two points using QGIS?

I have one input point layer and out of that, I want to create an output LINE vector layer. For each feature in my output line vector layer, I define a geometry which takes 2 point geometries. ...
1
vote
2answers
111 views

Output layer from PyQGIS 3 processing script is empty

I've created a processing script in QGIS 3, and although my output layer has shows a feature count greater than zero when using the feedback command, the resulting feature layer that appears in QGIS ...
0
votes
1answer
45 views

Dissolving using PyQGIS?

I have trouble to use function dissolve to dissolve polygons by field value in PyQGIS3. In PyQGIS2 this line was doing the job: QgsGeometryAnalyzer().dissolve(ki, "name.shp", onlySelectedFeatures=...
0
votes
0answers
17 views

Find diagram for understanding pyqgis

In orther to undestand the api of pyqgis, i'd like to konw where can i find a diagram of pyqgis api ?
1
vote
0answers
27 views

How to remove last created QgsRubberBand by clicking in Map Canvas area where doesn't exist any feature?

By combining information from these posts: Get the identified feature How to create and remove multiple QgsRubberBands in PyQGIS? I produced following code for getting feature attributes and ...
-1
votes
0answers
25 views

Create PDF with features of a layer

I want to design a PDF that contains the data of the different features of a layer and export it to PDF with pyqgis. Is that possible? I only see reference to print composer and I can't find a way to ...
1
vote
1answer
63 views

Making automatic updated date and time field in QGIS

I wish to create a field which automatically updates with the current timestamp when edits are made to a feature. I am using QGIS 3.4 and I am testing this using a shapefile. Following @Joseph's ...
0
votes
1answer
45 views

Applying graduated renderer to polygon using PyQGIS 3?

I'm trying to symbolize a polygon layer using a graduated color ramp, with no success. In the attribute field of my layer I have a column: 'PatCNT' with integer values from 2 to 6 for each row. I'...
-1
votes
0answers
16 views

Increasing vector layer font size using PyQGIS and Python 3?

I access layer label using this code. How do I increase the label size? pc=QgsPropertyCollection('gis_osm_places_free_1') pal_layer=QgsPalLayerSettings() pal_layer....
1
vote
1answer
38 views

Source of QGIS (3.x) Processing Tools

Is it possible to access the Python source code of the processing tools in QGIS 3.x (for example the Package layer tool) or is there a central code repository available?
2
votes
2answers
67 views

Struggling to use Field Calculator - PyQGIS

I'm using QGIS 3.4 (Madeira) and I am struggling to use python to calculate attributes of a new field in the attribute table. I have already joined a csv and a shapefile. I use the code below to ...
1
vote
0answers
14 views

Get the mouse event value from another module

I have two simple classes, one calls another. One of the classes is QGIS map tool and only returns the position of the clicked event to the method which activates maptool. I don't know how to do this. ...
1
vote
0answers
46 views

QGIS vector layer labels are not showing from python script

I have a python module, where a QGIS memory vector layer is created, within the same method that creates this layer I have constructed labels using: text_format = QgsTextFormat() label = ...
2
votes
0answers
37 views

Convert QgsVectorLayer.extent() to EPGS:4326

Many APIs such as overpass turbo require bounding box notation like (x_max, y_max, y_min, x_min) in EPSG:4326. However the method QgsVectorLayer.extent() returns values in the source's CRS. A possible ...
3
votes
2answers
69 views

Moving a geometry using PyQGIS3

I have a layer which has one feature. I try to move the feature(multipolygon) using the script below: layer = iface.activeLayer() for feat in layer.getFeatures(): prev_pos = feat.geometry()....
1
vote
0answers
52 views

Refactor Fields using PyQGIS3

I am trying to use Processing tool to automate refactoring for several tables: here is the code I am trying to use import processing input = 'C:\\Users\\Ehsan\\Desktop\\CIS WORK\\Sample files\\...
0
votes
0answers
34 views

PyQGIS 3.4: otb:unsupervisedkmeansimageclassification -> AttributeError: module 'processing' has no attribute 'runalg'

I'm trying to classify a raster with PyQGIS: import processing processing.runalg("otb:unsupervisedkmeansimageclassification","FalseColor.tif",128,None,100,3,1000,0.95,"class.tif",None) The python ...
0
votes
0answers
30 views

Qgis 3 Plugin, determine the kind of unload

Is there a way, a signal or another, to determine which way the unload function was called? by quitting Qgis by unloading the plugin by removing the checkbox in plugin dialog by de-install the plugin ...
2
votes
1answer
30 views

Changing QGIS system SVG path with PyQGIS

I am trying to change the SVG path with Python but I couldn't find any document which explains how to do this. This is what I want to do I Added SVG symbols to my plugin in a specific folder. When ...
1
vote
0answers
10 views

How to impose constraints on drop lists of two fields of the same layer?

Is it possible to impose with pyqgis3.0 some constraints on a drop list of a field attribute in order to govern the drop list attributes of another linked field? To better clarify this issue, I attach ...
3
votes
1answer
105 views

Get feature at specific coordinate with PyQgis

I am using QGIS 3.2 and I am trying to get the features at a specific coordinate for a specific layer. when I use mouse position event the following code works fine but when I calculate the coordinate ...
2
votes
1answer
99 views

Unable to export map with PyQGIS 3

I am trying to learn and work with PyQGIS 3. It is a very challenging task cause documentation is really limited and out of date. What I am trying to do is to: create a project add a layer save the ...
0
votes
0answers
25 views

S-52 Symbology in QGIS Standalone script

I have been working with S-57 file and am able to load all layers in a canvas in pyqgis stand alone script driver = ogr.GetDriverByName("S57") dataSource = driver.Open(file[0]) layersList = [] extent ...
2
votes
1answer
123 views

QGIS 3.0.2 Check if a field exists in a layer in Python

There are a few posts similar to this one, but none that I have found that hit it right on the head. My question is simply, how can you find if a field exists in a layer in QGIS 3.0.2 using Python? ...
2
votes
1answer
57 views

Why QgsFeature.geometry() returns an empty geometry in PyQGIS?

I am a new for QGIS, working in Python. I add a buildings(.shp) vector layer into QGIS, just like this: I'd like to get the geometrys of some features, then I can do analysis on the center point. ...