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]

Python bindings for QGIS.

1
vote
2answers
28 views

How to run the graphic modeler from the python console in QGIS?

How can I run the graphic modeler from the python console in QGIS?
1
vote
0answers
19 views

How to code in Python to select a region by a specific radius given a Lat Lon in the layer? [on hold]

I want to use python console(or script) inside QGIS to let users: input a Lot Lon input a specific radius (say like 250 meters from the input coordinate) Can anyone give me some hints on how to code ...
2
votes
0answers
17 views

Showing startup-messages on QGIS splashscreen

During the startup of QGIS there are status messages shown in the lower part of the splashscreen like "restoring loaded plugins". I am using a startup.py from which I would like to inform the user ...
0
votes
0answers
14 views

QGIS GPS information do not show elevation and other data

A little disappointed not to find an application that works for me. I give myself the task of developing it myself. I find the problem that QGIS does not show me some data, and the elevation is what ...
0
votes
0answers
24 views

How to Host QGIS Plugin

I want to host QGIS plugin such that anyone with the host link could be able to upload his data and see the output on QGIS desktop in the web browser. I tried to search on the internet, all I could ...
1
vote
0answers
10 views

Refreshing a composer map with Python doesn't seem to work

I want to do the equivalent of the button "Update view" in the QGIS map composer window, but directly from Python. I have the two following lines in my code, where composeur1 refers to the map ...
2
votes
1answer
19 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. ...
0
votes
1answer
23 views

Loading map from canvas in QGIS Composer created with Python?

I'm new to using Python to automate stuff in QGIS. I've used the following code to create a new map composer in QGIS: # create a new composer c1test = iface.createNewComposer("mon premier composeur")...
0
votes
1answer
21 views

QGIS Spatial Index uses bounding boxes; how to get actual nearest line to a known point

I have looked at lots of answers referring to this same issue, and tried using QGIS Spatial Indexes and iterating through the line features in the spatial index to calculate the distance between a ...
2
votes
0answers
18 views

Clipping outside QGIS with PyQGIS?

This is my first script and I having a problem trying to clip a shp file. I'm running on a linux server and this is my code: #! python from datetime import date from qgis.core import * from PyQt4....
1
vote
2answers
30 views

How to check if pyqgis layer is in layers panel without knowing its name

Is there an easy way to check if a layer created in pyqgis and addet to layers panel have been removed? I tried to use the layers = QgsProject.instance().mapLayersByName('my layer name'), but I don't ...
3
votes
1answer
28 views

Get xy coordinates of QgsMapCanvas in PyQGIS 3?

I am trying to get the QgsMapCanvas coordinates when they change using PyQt5 and PyQGIS 3. What I have used for that: self.canvas.scaleChanged.connect(lambda: self.showScale(self.canvas.scale())) ...
0
votes
0answers
7 views

How to change column's widget type on QGIS using Python [duplicate]

I need to automate customization of column's widget type in QGIS using Python, I know how to do it throw feature propreties>Fields, as shown in the picture below, but I can not find a python code that ...
1
vote
2answers
29 views

Remove official repository from QGIS

I would like to remove the official repository from several QGIS installations. Removing the Repository from the Settings works so far with: from qgis.PyQt.QtCore import QSettings settings=QSettings(...
1
vote
1answer
39 views

S57 Driver doesn't support update Error

I am trying to load S-57 file with pyQGIS with code below self.canvas = QgsMapCanvas() # self.canvas.useImageToRender(False) self.canvas.show() # Lay our widgets out in the main window using a # ...
1
vote
1answer
53 views

Exporting selected features to shapefile PyQGIS

I am trying to develop a script to export selected features on a layer to enable some automation. So far I have used this formula to import a layer and run a query. This ends up with features being ...
2
votes
0answers
18 views

Is it possible to create a QGIS workspace with pre-loaded layers, styles and print templates with Python?

I am building a python tool which aggregates data from a number of sources and generates some web-maps from this data. I was wondering if it is possible (maybe using PyQGIS) to create a QGIS3 ...
0
votes
0answers
6 views

Displaying picture in QGIS 3.X custom form (QT designer)

I have a problem with a function that worked well with QGIS 2.X but not with QGIS 3.X I want to display an image in a form made with QT designer. I followed this: In QtDesigner Add a new QWidget ...
2
votes
0answers
15 views

Splitting lines/creating vertex at intersection using PyQGIS?

I am looking for an easy way or function to split 2 previously selected line features (generate vertex) at intersecting points (or touching points). See the following picture: I am developing a ...
0
votes
0answers
18 views

Crash while creating composer in QGIS plugin

QGIS crashes when I am trying to create a Composer in plugin with the python code shown below. On the other hand, I can create and display new Composer with all layers (without using all "from qgis.* ...
1
vote
1answer
27 views

Split and merge polygons by ID and Feature value in python or QGIS

I have a spatial dataset with two major columns: county_name and group_ID. The spatial polygons are represented by each county_name. Some counties share the same group_ID, while some counties contain ...
0
votes
1answer
25 views

How to set checked “Auto Open Form” in identify results window, programatically?

I want to set check programmatically "Auto Open Form" check box in Identify Results window. Window is here and the check box is at the bottom-right: The Identify Results window is not open at that ...
0
votes
0answers
24 views

Querying attribute table in QGIS to return sum of subset?

I am using Jupyter notebook to query a dataset too big to be opened with excel and my pc is too slow to perform calculations directly on QGIS. My logic is as follows, after imported pandas: x = df[(...
0
votes
0answers
25 views

QGIS 3.2 -Couldn't load PyQt. Python support will be disabled

Somehow when I run QGIS. I get the following Python Errors; I have uninstalled everythin/Installed I tested with both stand alone version and OSgeo4w version they both have same issue. is there ...
1
vote
0answers
10 views

“Cannot find variable: staticmethod” message while running Processing script

Every time I run my own processing script in QGIS 2.18.22 I get this message fifteen times in Processing tab in Log Messages Panel : 1 Cannot find variable: staticmethod 1 Cannot find variable: ...
0
votes
0answers
20 views

Getting LayoutItemLabel from layout QGIS

I'm trying to modify selected layout items in a QGIS Layout using the python consol. I'm using the following code to access the selected items from the layout projectInstance = QgsProject.instance() ...
0
votes
0answers
5 views

How to disable all actions to digitize in pyQGis?

I'm trying to make a layer can not be edited, I already made a script that makes me disable my digitizing toolbar, but when I right click on the layer you can still make the editing commutation. How ...
1
vote
2answers
66 views

Zoom to selected feature in QGIS

While trying to read a layer from PostgreSQL, in order to select one polygon and zoom to this feature, I see the entire layer but not the selected feature. I am using an unconventional way solve the ...
0
votes
1answer
35 views

QGIS crashes when setting new Symbol to layer with python

I followed the QGIS 3 cookbook and created a new custom symbol layer class. But when I try to create a new the symbol, QGIS crashes. I create it like this. symbol = QgsMarkerSymbol({FooMarker(20)}) ...
0
votes
0answers
20 views

pyqgis different symbol color for vector layer

i have a script like below.I have a .csv file which contains lat,lon,data. How can i change symbol colors according to the data in the .csv file? from qgis.core import * from qgis.gui import *...
0
votes
1answer
51 views

Performing kNN between two 3D sets of points (pointclouds)

I have two overlapping pointclouds, for this example I take the first 10, A[0:10] and B[0:10]. They are stored as tuples, [(x, y, z),...]. I want to compare the two based on their nearest x,y,z ...
1
vote
1answer
28 views

Unable to execute Processing nativecentroid in python standalone scripts using PyQGIS

I am using QGIS 3.2 on Windows7. I had successfully set all enviroment variables in OSGeo4W shell. I have run small scripts without any issue. I have to run processing.run('native:centroids', {'...
1
vote
1answer
32 views

Access icons from within QGIS plugin with relative paths?

I have constructed a QGIS plugin using QGIS Plugin Builder 3.0.3. Within my plugin, I need to load a .png file as a Qicon object. What needs to be done for the plugin script to locate the .png file ...
0
votes
0answers
14 views

QgsTinInterpolator not respecting raster extent and origin

I am using QgsTinInterpolator to create an interpolated raster from a point Shapefile. I have an existing raster dataset that I'm using as a template to define the interpolated raster's extent and ...
1
vote
0answers
23 views

Silence qgis.core error messages in reticulate

I am using the qgis.core Python module in R using reticulate. I start the QgsApplication using the following code. # Start reticulate reticulate::use_python(Sys.getenv("PYTHONHOME"), require = TRUE) ...
6
votes
1answer
147 views

Change background color of Layer in the TOC / QgsLayerTreeLayer with pyqgis

I would like to change the background-color (or font color) of some items in the TOC of QGIS: Example-Mockup: I tried several ways but nothing did the trick so far: layer_list = QgsProject.instance(...
1
vote
0answers
32 views

How to render a vector layer using a QgsMapCanvas in QGIS 3? [closed]

I updated this ShapeViewer Demo for QGIS 3 and the layer does not render. All that shows is a white rectangle. The updated code is here. What am I missing?
0
votes
0answers
24 views

Exporting into Excel file from PyQGIS?

The following code allows me to save a text file with .xls extension in Python. When I open it, I receive the following warning: The file you are trying to open, is in a different format than ...
1
vote
0answers
58 views

QgsAlignRaster extent

I am trying to align rasters in pyqgis (snap raster ArcMap equivalent). There is a class reference in documentation, which is doing exactly what I need. QgsAlignRaster class. Anyway, my problem is I ...
2
votes
0answers
31 views

Changing the Location of Python Expressions QGIS3

I've recently started using QGIS and I've written a few custom functions to use with expressions in the Function Editor (see image below) From what I can find these appear to be saved in: C:\Users\...
1
vote
1answer
116 views

Automating conversion from .SHP to .GPX for thousands of shapefiles?

I am looking for a way to automate conversion from .Shp to .Gpx. I know how to save a shapefile into gpx in a layer, but it would take too much time to do 1 by 1 as we might receive thousands of ...
6
votes
3answers
113 views

Programmatically changing line lengths in QGIS?

Provided a set of lines with various lengths, I would like to change their lengths (hence, changing their geometry) to a specific value, using their centroid as base point. I have checked the ...
0
votes
1answer
59 views

Creating standalone python Script using PyQGIS?

I have written a code which solve my problem for Demand Allocation. I have Input (.csv)File and Output is also (.csv) File. However I have to integrate this script in Java Application.(https://...
1
vote
0answers
24 views

Locking QGIS and parent forms [closed]

I am trying to make a plugin for QGIS. This plugin has lots of forms and based on the condition the form calls a child Form. The following is an example I am using PyQt for creating forms. I want the ...
2
votes
1answer
27 views

Wait for user selection from user interface

I am making a custom maptool for QGIS I am overriding canvasReleaseEvent. when the user clicks on part of map canvas I call another function which identifies and creates a list of identified feature (...
0
votes
0answers
28 views

error “ValueError: API 'QDate' has already been set to version 1” when converting to standalone qgis script

I'm trying to convert a python script for qgis (2.18.2 Las Palmas) to executable (.exe) using pyinstaller This is a very simple example (I'm just a beginner): from qgis.core import * import os print ...
1
vote
0answers
22 views

Invalid data source in QGIS 2.18 [closed]

I am trying to run the raster process in QGIS 2.18. and every time I am getting an error as "Data source is invalid". What should I do? Python error that I am getting: 2018-09-24T13:56:09 1 ...
3
votes
1answer
37 views

Get not hidden fields in PyQGIS 3

I try to get a list of all fields - only they one which are not hidden - from QqsVectorLayer in QGIS 3 using python API. In QGIS 2 I used to do it like that: conf = layer.editFormConfig() for field ...
1
vote
0answers
34 views

How to fix self intersected polygons visually, as well in QGIS?

I have same invalid polygon features because of self intersection. I can make them valid by using fix geometries tool in QGIS 3.2. However I want to show them valid visually also. The feature is valid ...
7
votes
3answers
126 views

Aligning many rasters using PyQGIS or Python?

I want to align many rasters in some pixel size, extent and projection system using Python or PyQGIS. First think is to use GDAL: gdalinfo (to find information from reference raster) gdalwarp (to ...