Questions tagged [pyqgis]

Python bindings for QGIS.

Filter by
Sorted by
Tagged with
-2
votes
0answers
14 views

I want Aligning point along the line in ArcGIS with select line and point [duplicate]

I have a line and some points along with line and I want when selecting point and line, make point parallel in the same ways as you see in after in the below figure.
1
vote
0answers
22 views

QGIS layout manager has several A4 layouts: export them all to “the same pdf”

My QGIS layout manager has several A4 layouts. I would like to export them all to "the same pdf". I think that by going through the python console it should be possible. for now I can only print one ...
0
votes
0answers
9 views

Python parser somehow writes to file I did not specify?

So what I am trying to do is get options from configfile1 and write them to configfile2, simple. This works great if it would not be for the fact that somehow stuff gets changed in configfile1. After ...
0
votes
1answer
24 views

Register custom python function in QGIS Server 3.10

I have some custom python functions I have defined in QGIS which I use in print composer. I tried copying the python folder into the QGIS Server path but they do not get propagated. I have seen the ...
0
votes
2answers
41 views

Define categorized renderer with symbols based on several categories

In pyQGIS I have added a vector layer based on a CSV file. The CSV file contains several fields: x , y, Capacity, Category. I can render the map with simple points at the given (x,y) coordinates. ...
2
votes
1answer
39 views

Connecting Qt GUI to python code in QGIS Plugin

I am completely new to PyQGIS/PyQt and am having lots of trouble getting started. I have managed to create my base dialog box like so: The (automatically generated) code for the dialog is: import os ...
1
vote
1answer
25 views

Disconnect layer.selectionChanged when project is being closed or layer removed

On QgsProject.readProject I add a slot to some layer's selectionChanged. I tried disconnecting these slots in QgsProject.layersWillBeRemoved but here the project seems already closed, so I can't ...
1
vote
0answers
46 views

QGIS freezes while executing code

Im iterating through folders and subfolders to find shapefiles (~140 shapefiles, ~20 GB total) then applying fixgeometries and importintopostgis to import them to a postgis database. While code is ...
0
votes
1answer
20 views

PyQGIS in standalone scripts on Mac, import error

Following the PyQGIS Developer Cookbook to use PyQGIS in standalone scripts. Fixed the initial errors by setting the PYTHONPATH and DYLD_PYTHON_PATH to the appropriate folders but am now faced with ...
0
votes
2answers
32 views

Pass temporary output between definitions / functions to use as input to next def

Lets say I have two functions: class AnalyseDTM(): def __init__(self): self.DTM = ('C:/Users/EH/QGis/Kvit_Tiny.tif') self.CreatePolygons() self.test() def ...
0
votes
0answers
30 views

Error when displaying progress bar

My initial code read an image, apply a median filter to it, and save the smoothed image. It looked like this : #Image reading rasterpath = r"C:/Users/SIEXT5646/Desktop/Donnes/2018_gris.tif" ds = gdal....
2
votes
1answer
21 views

Rendering a map with Python works inside QGIS, but not in standalone script

I have an existing QGIS project and I want to write a standalone Python script that outputs a png file of the map. I work on Windows 10. This is the code that I use (basically taken from the PyQGIS ...
0
votes
0answers
33 views

Least Cost Path: interpretation of results

I am using QGIS 3.10.2-A Coruña and its built-in Python Console. I am currently trying to compute least cost paths between combinations of 2 points given a road network layer. For this I am using ...
2
votes
1answer
32 views

Delete subselected features with PyQGIS and processing

In QGIS 3.10, I have layers in which I select features by location (to find duplicates), using : selected_features = processing.run('qgis:selectbylocation', {'INPUT':layer1, 'PREDICATE':0, 'INTERSECT'...
2
votes
0answers
24 views

Import a layer in MySQL using PyQGIS

I managed to import a layer from a MySQL database in QGIS with PyQGIS. Now I'm looking to import a layer from QGIS into MySQL. I explored several ways : Using ogr2ogr on the command line, the ...
-1
votes
0answers
32 views

Divide polygon in equal areas in ArcGIS [closed]

How to divide an irregular polygon in equal areas in ArcGIS? When a point has been set on an Polygon edge.
2
votes
1answer
26 views

Project CRS Setting Invalid

Somehow, my attempt at setting the QGIS project coordinate reference system to a Sinusoidal projection by defining the CRS' EPSG ID returns "Invalid CRS!". I would be very grateful for any help with ...
2
votes
2answers
43 views

Using temporary output in a Raster Calculator algorithm

I'm doing some DTM processing, the first couple of stages are a slope calculation and then a Raster calculator process using QGIS's native raster calculator. I want to use the output layer from my ...
1
vote
0answers
22 views

QGIS Layout - Add image in attribute table

I am creating a layout of map using QGIS 3.10 I want to show attribute table with each point logo in table. I have a field which has the complete path to each logo and this field is already being used ...
6
votes
1answer
57 views

Load QGIS project from database using PyQGIS

I am trying to open a QGIS project that is saved to the database (Project -> Save to -> PostgreSQL) by means of Python script. I find a similar way to open project which is saved to the desktop ...
1
vote
1answer
22 views

Saving each feature symbology to a image using PyQGIS

I am attempting to write a plugin to export a LayerVector (Points) to images. I need to get the symbology of each point to export as images (PNG). My intention here is to create a new file containing ...
2
votes
2answers
54 views

Impeding PyQGIS saving changes to file on disk immediately

I am using QGIS 3.10.2-A Coruña and its Python Console. Currently I am modifying features and attributes of a shape file, e.g. dropping features: caps = layer.dataProvider().capabilities() if caps &...
-2
votes
0answers
19 views

Remove areas of polygon overlap with Python? [closed]

I have a collection of Polygons which have overlap in some cases: Now I want to erase polygons with each other based on the id of the feature: Some pseudo code: Order polygons by id For i in ...
1
vote
1answer
36 views

Getting all web services and database connections from QGIS in PyQGIS?

I need to write a plugin for QGIS but I am not very familiar with QGIS itself and kind of new to all of this. I want to get all connections programmatically. By connections I mean everything from WMS ...
0
votes
1answer
16 views

Create OAuth2 Authentication in pyqgis

I want to complete a code that should create same OAuth2 authentication on many other computers but with different usernames. I already tested creating basic authentication and it works fine. am = ...
0
votes
0answers
49 views

TypeError: 'tuple' object is not callable (QGIS 3)

I'm getting this error when trying to run the following code: line = iface.activeLayer() a = processing.run("qgis:fieldcalculator", {'INPUT':line,'FIELD_NAME':'len','FIELD_TYPE':1,'FIELD_LENGTH':10,'...
2
votes
1answer
37 views

Automatic “Extract by Expression” processing with PyQGIS

Refering to this post and particulary the etrimaille's comment, I want to clean my dataset created from OSM data in QGIS. In each layer, I want to extract the entities having a specific key and value, ...
2
votes
1answer
45 views

QGIS: loaded .shp file not displayed

I am using QGIS 3.10.2-A Coruña and PyQGIS via the internal Python Console (Plugins -> Python Console). Currently I am trying to import a shape file using the following command: vlayer = ...
1
vote
1answer
44 views

How to calculate field based on another fields [closed]

I´m trying to calculate field based on another fields. I´ve got this attribute table. Example: If field "Smisenost" is S than FRST in new field. Example 2: If field "Smisenost" is NULL, if field "...
1
vote
0answers
13 views

Download layer in a specific group from Overpass with PyQgis (via Quick OSM)

I'm writing a plugin for Qgis in python (pyqgis) to download OSM layers and apply some process to them. I use the Quick OSM plugin's code for the downloading part. I just call the "run_query(key,value)...
1
vote
0answers
35 views

Merge all separated lines with connecting extremities into single continuous lines

I got a DWG file from a friend that contains the curve lines of an area. However, once I import the file and then convert it to shapefile, all the lines are split. I would like to connect all the ...
0
votes
0answers
24 views

Importing QGIS 3.10 python module from system Python

I have QGIS 3.10 installed on my Windows 10 system and I want to import the qgis module from my system Python installation. I used this description on the QGIS homepage to set my system up. My ...
1
vote
0answers
37 views

Filter QgsAttributeTableModel without geometry

Is it possible to filter a QgsAttributeTableModel without geometries. I was not able to filter a QgsAttributeTableModel without geometries, so I added a fake geometry column to my table ("geom_fake"). ...
1
vote
0answers
33 views

Setup PyCharm to develop Python scripts for QGIS?

I want to set up for the first time an environment with PyCharm to write scripts for QGIS on my Ubuntu desktop and I'm completely lost. I'm not having problems with the console on QGIS, but I couldn'...
4
votes
0answers
31 views

PyQGIS: What objects need to be destroyed in a custom expression

I'm using a custom (PyQGIS) function in expressions to make little detailed minimaps around each feature in a layer, and store it in the layer (gpkg) as a png. My code works but makes QGIS (3.12) ...
4
votes
0answers
32 views

QGIS processing tools - saving/exporting graph

I just tried QGIS processing tools for the first time. When using shortest path search for the first time, the algorithm is building a path graph (of course). However, the graph is never re-used. ...
4
votes
2answers
71 views

Using Plugin in standalone PyQGIS script

Typically, when I want to use a QGIS processing tool for my PyQGIS standalone script I write something like: processing.run('buffer:...'{…}) Now, I would like to use the functionality of the QGIS ...
2
votes
1answer
44 views

Default Value for Field with Python Expression in Function Editor

I have a line shapefile in QGIS with several columns and the values for many of those columns could be automatically calculated and updated depending on certain other fiels. Now, I came across the ...
3
votes
2answers
157 views

Get only fields with datatype int in PyQGIS

With the following line of code, I get a list of field names for the layer layer. fields = layer.fields().names() However, I would like to get only those fields with the datatype Integer. How ...
1
vote
0answers
40 views

Drawing Line Starting/Ending at Pre-Existing Points in QGIS

I am trying to create a editing condition with a error message. The condition is while drawing a new line feature, line should start and end at pre-existing point feature. If user try to start or end ...
5
votes
2answers
62 views

Qt Designer forms and QGIS [closed]

How can you link a qtdesigner form from the QGIS itself, and to call a code made from the console?
0
votes
1answer
53 views

Saving 'OUTPUT': from processing toolbox to a file path with unique file name [closed]

I'm using the QGIS Toolbox and Python Console to write a script for parsing data. I want to do something like this: output_path = open('C:/Users/EH/Desktop/PYQGIS_Model_Output') # Set location to ...
2
votes
0answers
41 views

import qgis.core in Python

I am trying to use QGIS3.4 by using Emacs (elpy) on Mac OS Mojava. I checked following sources: https://docs.qgis.org/3.4/pdf/en/QGIS-3.4-PyQGISDeveloperCookbook-en.pdf http://osgeo-org.1560.x6....
4
votes
1answer
86 views

Adding constrain/check after adding first point of line and after last point of line

I want to customize the QGIS editing tool in the following way. Scenario: The first and last point of the line layer must have a point layer. Steps: User selects a line layer. User starts/toggles ...
2
votes
1answer
23 views

Define HTML Map Tip using PyQGIS

using PyQGIS, I need to create a map tip using this HTML code: ID = [% ID %] and style it like the picture below (white text and black background). I don't know how to use CSS in this case. If is ...
2
votes
1answer
53 views

PyQGIS: QgsVectorFileWriter.create() doesn't flush even after deleted

If QgsVectorFileWriter constructor is directly used, the output is flushed when the reference is deleted. I'm trying to switch to QgsVectorFileWriter.create() because QGIS warns that the former is ...
3
votes
1answer
54 views

Importing all layers open in QGIS to PostGIS

I'm looking for write a PyQGIS code to import all layers open in QGIS to PostGIS. import os #Code from https://gis.stackexchange.com/questions/26257/iterating-over-map-layers-in-qgis-python layers = ...
2
votes
1answer
57 views

QGIS plugin closing all open PyQt dialogs

In my QGIS3 plugin I need to close all open PyQt5 dialogs. The structure of my plugin is like the following code. To be clear, when I call runCloseDialogs() I want to close both dialogs opened by run()...
1
vote
1answer
34 views

Raster layer to GeoTIFF QGIS Python

Is there a way to export a layer in GeoTIFF format from Python? I am able to perform georeference with Python and show the results on the canvas. However, when I am inserting the .tif file in any ...
3
votes
1answer
36 views

Loading a symbol from db (symbology-style.db)

I'm working on a Qgis python module. I would like to apply a symbol on a layer by his name entry from the symbology database. I know that some defaults symbols are saved into a sqlite db (symbology-...

1
2 3 4 5
100