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
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [pyqgis]

Python bindings for QGIS.

0
votes
0answers
19 views

Qgis Python console not working

I have a small problem with the Python console in Qgis. I am working through some code .py but lately the console does not show results, for example I write directly on the cosola print "prueba" ...
0
votes
2answers
13 views

QGIS Processing Script - Add field to output

My objective is to add a new calculated field to the output layer from a processing script. This layer is created as follows:- source = self.parameterAsSource( parameters, ...
0
votes
0answers
10 views

Import own modules in custom forms in PyQGIS

I want to create my own custom forms using Python for QGIS, and since some of the forms will share some definitions and objects I would like to have my own classes for all of them. For that, when I ...
0
votes
0answers
20 views

Styling rubberbands using PyQGIS? [on hold]

I would like to add an on-map drawing function in my stand alone app, so I used QgsRubberBand to make it. I made a tool that emits points and then draw the QgsRubberBand. The problem is I don't find ...
0
votes
1answer
33 views

Can't delete features from layer tables in QGIS

I have some layers containing DAT,MAP and TAB files, when I loaded these layers into QGIS some layers have check boxes before layer name and some layers won't like showing in below image. In the ...
0
votes
0answers
6 views

Grouping layers using PyQGIS makes them not visible on canvas?

I've tried using the information in the following posts in order to group layers in PyQGIS (Qgis 3) Adding layer to group in layers panel using PyQGIS? Adding layer group using PyQGIS? https://docs....
1
vote
0answers
22 views

QGIS crashes when toggle editing for the child layer in a QgsDualView

The crash occurs for : Ubuntu 18.04 bionic QGIS 3.4.2 For reproduce the crash, I use these data : https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/...
1
vote
0answers
26 views

Get column index by name in QgsAttributeTableModel

In a QSqlTabelModel I can get the index of a column like this: my_table_model.fieldIndex('column_name') How can I do the same with a QgsAttributeTableModel? I have tried .fieldCol and .fieldIdx, but ...
1
vote
1answer
34 views

Disconnected features in Python, QGIS

I'm working with code from the Disconnected Islands plugin in QGIS x64 and Python. Normally, the plugin ends by writing the FID of features to a CSV and their corresponding network group ID. Instead, ...
1
vote
1answer
38 views

Rotate SVG marker angle based on each feature's value

I'm importing data, and creating a layer, which has a number of features, each with an f_angle attribute. I'd like to create a data defined override to rotate the SVG marker by the angle defined by ...
0
votes
0answers
16 views

Avoid duplicate labels using PyQgis code [on hold]

I am trying to label street's names. Each street includes multiple sections. I have many repeats of the same street's name. I want to avoid it. I can't find any information how to do it. It must be ...
-2
votes
1answer
40 views

Using PyQgis to count number of features in category [on hold]

Is there a way I can use pyqgis to count the number of features in different categories in one layer? I am using rule based renderer, and realizing that for some rules the feature count is actually ...
0
votes
0answers
10 views

ArcGIS Mapserver Layer via pyqgis with dynamic layer properties

Is there any possibility to add esri mapserver layers to qgis with dynamic layer properties such as transparency,etc. iface.addRasterLayer("url='https://sampleserver6.arcgisonline.com/arcgis/rest/...
0
votes
0answers
66 views

Python Scripting in QGIS to add features and select them?

I'm trying to migrate a python plugin I wrote from QGIS 2.18 to QGIS 3.4. In the plugin, I'm creating new vector features and eventually adding them to an existing vector layer. I'm trying to have the ...
2
votes
1answer
47 views
+50

Print Layout Items. setExtent() and attemptResize()

I'm trying to arrange some map items onto a print layout. Let's start with the map item itself. Here is my code to add a map item to the print layout. Specifically I have questions about the ...
1
vote
1answer
25 views

QgsfeatureRequest - Store result indexes

I recently posted a question. My original goal was to find a way to determine on which side of a line points are located. @xulnik answered this question with two codes. One returns a binary [0;1] ...
0
votes
0answers
23 views

Debugging a QGIS 2.x plugin using pycharm? [on hold]

I'm looking for the possibility to debug a QGIS plugin using Pycharm IDE Without the help of Remote-Debugger. For instance, when someone tries to code the plugins on an IDE such as Pycharm, It's the ...
2
votes
1answer
27 views

How do I change 'Coordinate Display' for a project, programatically?

From the user interface in QGIS, I can change the coordinate display (unit) for a project by going to: Project > Properties... > General (tab) and under the Coordinate Display section can ...
2
votes
1answer
40 views

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
2answers
55 views

Creating a fixed distance buffer from a virtual layer

First off, i'm trying to learn some python to automate scripts for basic tasks i carry out in QGIS (2.18). Below I create a virtual layer (polyline) using the following script: from qgis.core ...
2
votes
0answers
33 views

How to find how grass's r.viewshed works programmatically?

I want the Python source code of Grass's Viewshed analysis. In QGIS software there is only an .exe file of that algorithm. Although I'm not sure whether it's written also in python or not. Where can ...
2
votes
1answer
31 views

Show custom QgsAttributeTableView

I'm setting up a custom widget in a QGIS3 plugin and include a QgsAttributeTableView like this: layer = iface.activeLayer() layer.getFeatures() canvas = iface.mapCanvas() vector_layer_cache = ...
0
votes
0answers
12 views

QGIS 3.4 - Access Violation no RTTI data

i'm used to writing in C for embedded systems, so python is somewhat new to me. I've built up this script in QGIS script editor following the template. However, when I run the script I get an Access ...
1
vote
1answer
148 views

Invalid geometry vs. no geometry

Looking at the QGIS API Documentation: bool QgsFeature::hasGeometry Returns true if the feature has an associated geometry. Is invalid geometry different from a feature having no associated ...
3
votes
0answers
37 views

Unable to compute intersection between two polygons using PyQGIS?

I have two polygons in different layers. I am trying to find the intersect between the two polygons. Below a figure showing my test case. I initially wanted to find the intersect between the green ...
3
votes
2answers
69 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 =...
0
votes
0answers
20 views

IDE's syntax completion doesn't work fine while using PyQGIS library!

I use a batch file to set everything up in Pycharm but while I want to use "iface"(which is the QGIS interface instance), my IDE wouldn't recognize it and Its arguments. My batch file is like this: ...
2
votes
1answer
51 views

QGIS Python matching list values to feature ID

Working in QGIS 3 x64 with built-in python console and editor. I have a list of the feature IDs of duplicate features in my dataset. Ultimately, I want each of these features to have a value of 1 ...
1
vote
1answer
84 views

Determine on which side of a line points are located

I have a point shapefile (point.shp) and a line shapefile (line.shp). I want to determine on which side of the line each point is located. The best would be to use a pyqgis command to add a field to ...
1
vote
2answers
32 views

Point Sampling Tool pyQGIS

I have several raster files (raster_1, raster_2, [...], raster_n) and a point shapefile. The point shapefile (point.shp) was created using "generatepointspixelcentroidsinsidepolygons" so my points are ...
0
votes
1answer
26 views

Using QMessageBox to debug during QGIS plugin development?

I am developing a plugin in QGIS 3.4 and usually I debug with QMessageBox. Everything is running ok until I debug a list and the result was this one. What happens?
0
votes
1answer
24 views

PyQGIS import from UI class problem

I've tried to build a plugin from scratch to better understand the plugin structure and so on without the help of PluginBuilder or similar tools so my code could contain flaws. I went through every ...
1
vote
0answers
15 views

Qgis Python Plugin leaves orphaned variables in RAM, even after plugin reload [closed]

My python plugin for QGIS 2.18 opens files with millions of features. To convert them in Qgis readable format, I run through several external python libs, one of them is a R-Tree tool, consuming 10G ...
1
vote
1answer
44 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. ...
3
votes
3answers
149 views

Following QGIS Python Programming Cookbook to create vector layer in memory? [closed]

I got the QGIS Python Programming Cookbook Second Edition, in hopes of improving my abilities around QGIS as well as making me confident in using Python. Keep in mind that my programming abilities are ...
0
votes
0answers
25 views

QGIS plugin - Works on PC, not on Mac

I'm adding some functionality to an existing QGIS plugin (EcoValuator from Key-Log Economics). After playing with the existing version of the plugin, it works on a PC, but not on a Mac. The issue is ...
2
votes
1answer
44 views

Assigning function to a key in QGIS Plugin

I have trouble assigning function to a hotkey in my plugin. I have a class that does things with a mouse click. I'd like to assign another function to a keyboard key or sequence. I've tried two ...
2
votes
1answer
54 views

How to keep QGIS plugins always on top of the main window?

When writing a simple QGIS 3 plugin via Plugin Builder 3, is there a simple way to tell QGIS not to hide the dialog box when the mouse clicks outside it? I have tried a few options without luck, How ...
3
votes
1answer
80 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
36 views

How to fix 'Could not find the Qt platform plugin “Windows” in “”' when implementing qgis in custom Python3 application?

I am implementing qgis 3.4.3 in a custom application, but when I instantiate the QgsApplication() class, I receive the error "Could not find the Qt platform plugin "Windows" in "". I've attempted ...
2
votes
0answers
31 views

Dijkstra/Finding shortest path gives back a tree with only -1 in it

So I'm trying to implement a routing algorithm in my QGIS 3 plugin that I'm writing using Python. I think I could resolve all the problems concerning the break between QGIS 2 and 3, but my resulting ...
1
vote
1answer
37 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
100 views

QProgressDialog in QGIS 3.0 not updating

I am using a QProgressDialog to show the progress of a routine that is running. I found this very helpful question/answer how-to-show-a-moving-progress-bar-in-qgis, but I can not reproduce successful ...
0
votes
0answers
36 views

Looping through Clip Raster By Mask function

I created a script to loop through the Clip Raster By Mask function. I assign my personal files to the variables and use a nested for loop to iterate through the feature ID numbers in my selected ...
2
votes
1answer
34 views

Create a polygon with a list of coordinates gave by QInputDialog in pyqgis console

I have a problem when i run this script. It gives me: TypeError: QgsGeometry.fromPolygon(unknown-type): argument 1 has unexpected type 'list' Here is my code: # -*- coding: cp1252 -*- from qgis....
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 ...
2
votes
1answer
45 views

Using parameterAsSink in QGIS processing script?

Note I have edited this question to make it more direct and hopefully get a response. I am attempting to write a series of processing algorithms to automate and extend a workflow in QGIS 3.4. I have ...
1
vote
0answers
23 views

pyqgis : Load WMS layer and make him invisible (qgis 3.4.3 ) [duplicate]

I am loading WMS layer in Python console with simple code. Then I try to make the layer invisible in TOC, but not success. I run the code in QGIS 3.4.3 in Python console in Windows 10. I will be ...
1
vote
1answer
39 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 ...