Questions tagged [pyqgis]

Python bindings for QGIS.

Filter by
Sorted by
Tagged with
0 votes
1 answer
39 views

Iterating over the features of a vector layor then performing zonal statistics algorithm on each feature in PyQGIS

I composed this script in PyQGIS to perform the zonal statistics on a vector layer as for all its features at once, it works perfectly, when the script is finished, I inspected the attribute table and ...
Khaled's user avatar
  • 257
0 votes
1 answer
24 views

Datetime from attributetable to layername in QGIS with Python

I have several (point) layers and I want for all of them this > Take the first value of the "datetime" column and append it on the layername. These point layers come from gpx track ...
Immo Woschny's user avatar
1 vote
0 answers
44 views

Output file not generated by r.viewshed in PyQGIS

I'm trying to use r.viewshed in PyQGIS to perform Viewshed analysis on a point placed on a raster layer. The algorithm seems to run correctly, as no errors come up, but the output .tif file is not ...
oliver's user avatar
  • 11
1 vote
1 answer
34 views

Depth Band "> 1.20" isn't being extracted, could the > be affecting the extract?

We have created a code to extract the different bands of flood depths from the EA and it works extracting '0.00 - 0.15', '0.15 - 0.30', '0.30 - 0.60', '0.60 - 0.90', '0.90 - 1.20' ranges. However, it ...
Jack's user avatar
  • 13
0 votes
1 answer
78 views

Centering layer on QGIS map using Python

I created the print layout using Python and I'm inserting this snippet of code to create a location map, but even though the code works I'm having difficulty centering a layer called municipalities in ...
Raíssa Daher's user avatar
0 votes
0 answers
29 views

Error on deleting vector file written by QgsVectorFileWriter on Windows

I wrote a QGIS plugin which writes vector layers to vector files using PyQGIS method QgsVectorFileWriter.writeAsVectorFormatV3(). I then use different processing methods to clean geometries, etc. and ...
geraldo's user avatar
  • 960
0 votes
0 answers
83 views

Pretty "buffer" around Point-Layer with as little as possible Vertices [closed]

I'm searching a solution (which I can automate) for getting my Area of Interest around Points of Interest. I've got a point-layer in QGIS. I want to have all the area which is inside a 0.5 m Buffer ...
fsg's user avatar
  • 672
3 votes
1 answer
103 views

"Could not load source layer for INPUT" error when reprojecting flt-file with PyQGIS

The data I have are ESRI Floating Point Data (so they are a raster type). The path I provided is a fake path, so that I don't show my real system paths. I know that my code works with vector data, as ...
i.i.k.'s user avatar
  • 1,271
4 votes
1 answer
146 views

Cloning the map layer using PyQGIS

I want to clone my generated memory layer and apply different filters and symbology. The clone is visible in the layer tree, but doesn't show up in the canvas. What am I doing wrong? uri = f'point?crs=...
Redoute's user avatar
  • 2,164
0 votes
0 answers
30 views

Could a temporal controller QgsDateTimeRange be a bug?

I am having an issue with getting date/time specified raster layers to animate. In trying to resolve this, I printed out the .dateTimeRangeForFrameNumber(fn) just to ensure the datetime start and end ...
Robert J Ricks Jr's user avatar
0 votes
0 answers
15 views

Pydev Remote Debug Breakpoints with QGIS Stops in _string_ instead of the python file

I tried to use the remote debugger with PyDev but when I reach the breakpoint, I end up in a file name "string" that seems to be internal commands: To set up the remote debuger, I followed ...
Biorix's user avatar
  • 31
1 vote
1 answer
32 views

Resample Raster in PyQGIS with Median Approach

I have a raster file with a spatial resolution of 2m x 2m. I want to resample the raster from a 2m by 2m resolution to a 25m by 25m resolution in PyQGIS. My approach is using the Nearest Neightbour to ...
eagleadmiral's user avatar
0 votes
3 answers
71 views

Saving selection as new layer after using array for filter expression in PyQGIS

I am selecting features based on whether "ZIP_CODE" value is found in an array. I am getting matches with the following: layer = iface.activeLayer() array = [93013, 35007] matches = 0 for ...
Simon Palmer's user avatar
0 votes
0 answers
13 views

Fixing IndexError from QGIS Weights of Evidence (WofE) plugin

I am using the QGIS plugin Weights of Evidence (WofE) plugin (https://github.com/chudasama-bijal/QGIS-Plugin-Weights-of-Evidence-Model). When I perform the 'Calculate Weights' step using the Evidence ...
JSAV's user avatar
  • 1
0 votes
0 answers
22 views

QGIS panning with setExtent() eventually causes the map canvas to stop loading

I have written a python script to automatically scroll/pan across the map canvas along a specified path. The script is based off a thread that emits a signal to a handler that does this: def ...
Eanema's user avatar
  • 51
0 votes
0 answers
25 views

8 Threads in Processing Scripts Access Violation Crashes [closed]

maybe I just need some help understanding how qgis threads work but I have the following problem. For example: Script A: Processes a point layer and saves the number of points in each cell of a vector ...
Fer RR's user avatar
  • 1
0 votes
0 answers
35 views

QGIS rasterize with field as value, outcome only captures part of values in the field

I have a vector file with multiple polygons with a column named all_cert. I want to rasterize this data but everytime I do, the resulting raster file only contains pixels with values for certain areas ...
Evelina's user avatar
2 votes
1 answer
100 views
+50

How to Delete Output of the Processing Tool in PyQGIS

I have been developing a processing tool that iterates through polygons, and for each polygon, I perform hydrological processing and call various processing tools such as 'native:clip', 'saga:...
Nil's user avatar
  • 1,467
-2 votes
0 answers
76 views

Remove dropdown from QgsSymbolButton [closed]

I want to remove the dropdown from the QgsSymbolButton.
Nukufel's user avatar
1 vote
1 answer
68 views

Incorrect output when smoothing line that intersects multiline with PyQGIS

I wrote a such script to smooth my line. It checks whether a line of two points intersects the border of a polygon and, if not, then draws a line. This script works well for a simple example, but bad ...
redhat's user avatar
  • 327
0 votes
1 answer
68 views

PyQGIS print map with different aspect ratios

I have multiple maps generated in a pyqgis script. Those maps I want to export them automatically with different aspect ratios in order to be printable on different canvases. This is the list of ...
Marin Marian's user avatar
2 votes
0 answers
56 views

PyQGIS setting scalebar to kilometers

I have a pyqgis script that exports multiple maps. I am using a specific layout and map item. The scalebar should be variable depending on the location. I have the following scalebar code snippet: ...
Marin Marian's user avatar
0 votes
0 answers
22 views

Nearest Neighbour on route vs Shortest Path

I have a line layer “Cables” which represents my network, and this is formatted correctly so all lines are in the correct direction. I have a node layer “nodes” that sit directly on top of the lines. ...
30136353's user avatar
2 votes
1 answer
42 views

How to update QGIS display from script run in console

Working from the Python console in QGIS, I am trying to create an 'animation' of sorts by selecting one line after another in a layer with parallel lines, with a pause on each line. I've started from ...
marcp's user avatar
  • 895
0 votes
0 answers
23 views

Calculate between features in sequence without matching ids with PyQGIS

In another question (Loop an operation in all features) I asked about calculating the time difference between features, I was told that I could use this code (this code is from BERA): layer = ...
Mestrexama's user avatar
4 votes
1 answer
133 views

TypeError when converting QgsMultiLineString to QgsGeometry using PyQGIS

I have previously written some PyQGIS code to replace the features in a LineString layer with new features. The outline of the code is below - I have left out the specific code to create data for the ...
Tom Brennan's user avatar
  • 4,407
3 votes
0 answers
121 views

Add multiple raster from a for-loop in PyQGIS

I want to use the raster calculator to add multiple rasters in PyQGIS [raster 1 + raster 2 + raster ...}. The rasters are from a for-loop. I do not manage to get the temporary files from inside the ...
eagleadmiral's user avatar
1 vote
1 answer
88 views

Error when adding new feature

I wrote a python script for QGIS to create an empty SpatiaLite layer, which the user later can fill with features: import sqlite3 DBdir = r"Test.sqlite" SPATIALITE = r"path/to/dll"...
Dennis's user avatar
  • 35
1 vote
1 answer
102 views

Exploding lines with PyQGIS [closed]

Are there ways to realize exploding lines through PyQGIS? I have layer with very complicated line and exploding lines is so slow, it doesn't end even after an hour. I've created spatial index and run ...
redhat's user avatar
  • 327
1 vote
0 answers
23 views

Synchronizing qgsofflineediting database data back to remote layers using PyQGIS

I have a situation where I need to find the path(database) of GeoPackage, if the path has already exist then I need to use the existing GeoPackage data to load the offline data using qgsofflineediting ...
Nihar Sahoo's user avatar
0 votes
1 answer
39 views

Python from pathlib import Path crash into QGIS

I'm creating a custom Python script inside QGIS Processing in Mac OS system, I encountered a serious error cause a crash of QGIS application. If in my Python script I use this library: from pathlib ...
gianfranco di pietro's user avatar
1 vote
0 answers
29 views

QGIS raster calculator using Python console

I want to calculate sum values of many rasters (from input folder) in QGIS Python using raster calculator. When I run script, QGIS crashes: Windows fatal exception: access violation import os from ...
user238054's user avatar
2 votes
1 answer
40 views

Adding geometry from first row of attribute table to all other rows of attribute table of layer using PyQGIS

I have a layer where only the first row in the attribute table has a geometry. I want to copy this geometry to all other rows of the attribute table of this layer but the geometry is still empty. ...
Robert B K's user avatar
0 votes
0 answers
45 views

Shortest path point to point Error

I'm new in Python and QGIS I try to build the shortest path in a line layer and got an error "There is no route from start point to end point" because of point line projection. I'm trying to ...
redhat's user avatar
  • 327
0 votes
0 answers
14 views

Dynamic WHERE clause in setDataSource in PyQGIS

In PyQGIS, I want to create a layer according to the value of two variables (not hardcode values). This is a piece of my code, but the layer is not valid. var_a = "Miami" #hardcode var_b = &...
gpo's user avatar
  • 1
2 votes
1 answer
55 views

How to hide or remove the subgroup labels on a QgsLayoutItemLegend with PyQGIS?

I'm trying to build a layout with pyqgis and I'm not able to hide or remove the label from the caption subgroup as shown in the image below. This is what I have until now: ... legend = ...
Francisco Camello's user avatar
0 votes
0 answers
22 views

QgsLayerMetadata.combine(other) doesn't seem to work as intended in pyqgis application

Using Pyqgis, I am attempting to create rasters from some calculations then applying a stored metadata.qmd file from an elevation layer to those rasters as a default. I am able to successfully create ...
Robert J Ricks Jr's user avatar
0 votes
0 answers
24 views

How to automate the code to synchronization postgis live layer on pyqgis?

I possess a dataset stored on a PostGIS server and aim to establish a fundamental synchronization mechanism through code. Although I've implemented the provided code for this purpose, when utilizing ...
Nihar Sahoo's user avatar
2 votes
0 answers
38 views

How to exit nicely from a PyQGIS plugin in QGIS

How do I exit nicely from a PyQGIS plugin in QGIS, for example: def run(self): # Run the dialog event loop, will return 0 (integer, true) result = self.dlg.exec_() # ...
LeasMaps's user avatar
  • 735
0 votes
1 answer
60 views

PyQGIS: Transform Lat-Long CSV into a UTM project

I have a UTM project in QGIS and need to import some CSV files that are in Latitude Longitude format. When I import it using the GUI, it knows that it is in CRS: 4326 and does a ballpark reprojection ...
JeffF's user avatar
  • 3
0 votes
0 answers
44 views

Setting custom CRS using PyQGIS

I have a PyQGIS-script which reprojects to EPSG:25832. However, it needs some adjustments in the false_northing and false_easting parameters, therefor I tried to create a custom CRS with adjusted ...
i.i.k.'s user avatar
  • 1,271
0 votes
2 answers
87 views

Reprojecting to EPSG:25832 using PyQGIS shifts layer

I have a shapefile with the following CRS specified in the prj. file, and I think it is ESRI:31493 : PROJCS[ "Germany_Zone_3", GEOGCS[ "...
i.i.k.'s user avatar
  • 1,271
0 votes
0 answers
51 views

QGIS Plugin development : Error when running the plugin code in the QGIS Python code editor

When running my main dowload_boku.py code in the Python QGIS code editor I get an error. While the plugin itself is working in QGIS. Anybody an idea? The error occurs without any adjustments to the ...
Daniel_Boku's user avatar
0 votes
1 answer
43 views

Does QgsSpatialIndex() support Z values, respectively 3D distances?

I am wondering if QgsSpatialIndex() does support Z values, respectively 3D distances? If too short to read: Looking at the underlying libspatialindex I cannot find information neither. However, rtree ...
MrXsquared's user avatar
  • 33.8k
1 vote
1 answer
58 views

Projects points to lines inside a polygon

I try to project points onto a line layer. The line layer consists of lots of simple lines (I got it from Voronoj diagram, it is a center line of my polygon). I need to draw path from start point to ...
redhat's user avatar
  • 327
3 votes
2 answers
112 views

How to auto-update field on geometryChanged() signal?

I have a point XY layer with a Z field used only for annotations. Sometimes there is a need to update the the geometry by moving the point manually. Since the layer is stored on an mssql server, the X ...
Ivan Marjanović's user avatar
0 votes
0 answers
16 views

PyQGIS: Create feature on Layer A when splitting Layer B

I have a CompoundcurveZ Layer A with the fields fk_to, fk_from, elev_to and elev_from. The foreign keys reference a PointZ Layer B. I am now trying to setup a python action on Layer A that uses qgis....
cymed's user avatar
  • 155
-2 votes
0 answers
23 views

WFS - download all layers from list [duplicate]

I have a list of WFS connections, of which there are 380. I would like to automate the retrieval of all layers from the entire list. Any solutions?
Łukasz Maćkiewicz's user avatar
0 votes
0 answers
43 views

Least cost path plugin

For my Bachelor's thesis I try to calculate the least cost path inside a polygon. The Least cost path plugin is good for it https://plugins.qgis.org/plugins/leastcostpath/#plugin-versions. But I need ...
redhat's user avatar
  • 327
1 vote
1 answer
40 views

PyQGIS layer action: Select features within buffer having the same field value

By means of a PyQGIS layer action, I am looking for a way to select all polygon features within a buffer polygon sharing a certain field value (e. g. provinces belonging to the same country) with the ...
ebcs's user avatar
  • 49

1
2 3 4 5
151