Questions tagged [pyqgis]

Python bindings for QGIS.

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

PyQGIS shapefile feature field indexing fails [closed]

I have a shapefile with multiple fields/columns/attributes (in my understanding these are all names for the same thing). Looking at it in the attribute table everything looks as expected as well as ...
3
votes
0answers
22 views

Split polygon based on location of features in overlapping layer in QGIS

I have a polygon layer of parcels and another polygon layer of houses. I'm looking for a way to split the polygons in the layer of parcels in such a way that the border between the new and old parcel ...
1
vote
0answers
25 views

Create a empty geopackage with pyqgis

I'm trying to create a new GeoPackage with an empty layer in it. I tried this code from this answer. from qgis.core import * from qgis.PyQt.QtCore import QVariant QgsApplication([], False) ...
0
votes
1answer
19 views

Rewinding qgis._core.QgsFeatureIterator

How to use qgis._core.QgsFeatureIterator.rewind() correctly? Executing features.rewind() returns False.
1
vote
1answer
34 views

How to create a curvy line joining 3 points in pyqgis3?

I am trying to draw a curvy line joining 3 points. I was using https://webgeodatavore.com/create-qgis-curve-from-python-api.html as reference but it is not giving desired output. I used ...
2
votes
1answer
44 views

Filter layer by FID with PyQGIS

I would like to duplicate a layer and apply a filter on the new layer that contains only selected features. Requirements are: using a memory layer is not an option, I want to keep the original ...
0
votes
1answer
23 views

Load layers with PyQGIS from ArcGIS feature service

When opening QGIS and add connection to the ArcGIS Feature/Map Service like :https://gis.adem.alabama.gov/arcgis/rest/services it giving me the list of all services and the layers within each service. ...
1
vote
0answers
26 views

Batch adding of SEGY files to QGIS

I am working with a set of legacy Archaeology GPR data that contains a massive batch of .segy files. Each file has multiple layers forcing me to "Select Vector Layers" to add. Is there a way ...
-1
votes
0answers
12 views

Check feature attributes before save [closed]

I would like to check my features before recording. The QgsAttributeForm::beforeSave signal would work for me but it's not possible in Python... Do you have any ideas?
0
votes
0answers
19 views

Making icon and text size change when map scale changes using PyQGIS [closed]

To show icon and text of my position on QgsMapCanvas, I add a QgsAnnotationLayer and add a QgsAnnotationPointTextItem for text and add QgsAnnotationMarkerItem for icon to this QgsAnnotationLayer. How ...
0
votes
0answers
10 views

Extracting contours from mesh layer in QGIS?

I am writing a C++ application that loads a NetCDF file as a mesh layer. I am attempting to utilize the QgsMeshContours class to export line geometries to be appended to a memory vector layer. ...
0
votes
1answer
31 views

Error with processAlgorithm [closed]

I am preparing a procedure with QGIS that can also work as a python script both in the QGIS python console and in a standalone procedure. The procedure works in the QGIS graphical modeler but not in ...
0
votes
0answers
16 views

Custom symbology for mesh layer in QGIS? [closed]

I would like to plot wind data using traditional wind barbs instead of arrows for a mesh layer, but there doesn't seem to be anything within the QgsMeshRendererSettings class to enable this; and the ...
4
votes
0answers
40 views

Passing a Geometry object to processing algorithm

In ArcPy, you can pass a geometry object as parameter to geoprocessing tool: import arcpy coordinates = [[20, 30], [30, 30], [30, 20], [20, 20]] array = arcpy.Array([arcpy.Point(x, y) for x, y in ...
0
votes
0answers
20 views

Nested for: I execute changeAttributeValue in the outer loop, print it and is still NULL... but inner loop works kind of fine?

A bit hard to explain, untill now my script is: I have a for, where: if an "Analized" attribute is NULL, I will change it to "Parent",store a "Join Value" attribute in a ...
4
votes
1answer
68 views

QGIS - set an Action checked by objectName (SnappingTool - EnableTracingAction)

I would like to enable the Tracing Tool at QGIS startup. With the following code, this works great. for x in iface.mainWindow().findChildren(QToolBar): if x.objectName() =='mSnappingToolBar': for ...
2
votes
0answers
15 views

Setting mesh layer visibility in QGIS application?

I am utilizing the QgsMeshLayer class to load a NetCDF file that contains multiple variables (temperature, velocity, etc). I want to be able to set the visible dataset by variable name. I know how ...
2
votes
0answers
26 views

Run PyTorch within QGIS Plugin using PyQGIS

I would like to run my object detection module (programmed in PyTorch) in a QGIS plugin. Currently, I have implemented all the required functionality in the QGIS plugin (getting the image, selecting a ...
5
votes
1answer
96 views

Assigning layer feature to another layer having same name in table using PyQGIS

I have 3 groups of layers, layer names are the same in the 3 groups as shown in this image below: : I want to make a table of 4 fields: layer names of group (1), layer lengths of group (1), Feature ...
2
votes
0answers
49 views

Cannot use TEMPORARY_OUTPUT in standalone PyQGIS script

I have a PyQGIS script that's running perfectly fine in PyCharm but I cannot get it to work from command line. I keep getting the following error on the first processing call which turns out to be a &...
3
votes
1answer
65 views

Apply the script on two groups of layers

I have two groups of layers, and I'm applying the same processing script to each of them, Is there any way to include the two groups in one script rather than repeating the script? #find group from ...
1
vote
2answers
59 views

Setting name of output layer PyQGIS

The script below is to merge number of layers in a specific group, the output layer name is Merged. How can I change the name? I tried to change the output parameters but it's not working. root = ...
0
votes
0answers
20 views

Coordinate transformation of QgsMeshLayer programatically?

I'm using the MDAL provider to load NetCDF data as a mesh layer in QGIS (3.20). The CRS metadata I wrote for the files doesn't seem to translate to QGIS, so I tried to make use of the ...
0
votes
0answers
29 views

I am facing an error in QGIS with the name "An error has occurred while executing Python code: " [closed]

The error is caused by Update tables in a plugin named MOLUSCE.
1
vote
0answers
42 views

Export QGIS layout as georeferenced PNG image with PyQGIS

I am using PyQGIS to export a map layout like this exporter = QgsLayoutExporter(layout) settings = exporter.ImageExportSettings() settings.dpi = 100 path = 'C:/data/test1.png' exporter.exportToImage(...
3
votes
1answer
38 views

Nested for: Outer for doesn't iterate

I wrote a code with a for nested inside another for. When I execute the code, the outer for starts with the first feature, runs as expected, then gets in the second for, runs it as expected, but then ...
4
votes
1answer
45 views

Access to consecutive features in PyQGIS loop

I have a point shapefile and I want to calculate the radius of the circle passing through three consecutive point and append it to the line that passing through two consecutive points. For this, I'm ...
1
vote
1answer
22 views

Scale Factors application not working on GEE PyQGIS

I'm trying to load some Lansadt 7 Collection 2 images on a QGIS project trought the following script: import ee from ee_plugin import Map ecorregiones = ee.FeatureCollection('users/paullcfias/...
0
votes
0answers
35 views

Georeferencing PNG image by GDAL in QGIS

I am not familiar with GDAL so far. Thereby I don't know how to start. By knowing the problem from the question below: Georeferencing PNG image in QGIS when the coordinates of image corners are known ...
3
votes
2answers
69 views

Adding today's date to attribute table using PyQGIS

I have the following script to merge a group of layers, and I want to edit the script to add a field containing today's date in the attribute table and also delete some fields by their names? root = ...
0
votes
0answers
33 views

Adding feature count of layers in table using PyQGIS [closed]

I have a group of layers and I want to make a table of two columns(Layer name, feature count) for this group, I tried the following script but it shows the same number for all layers. Can anyone tell ...
2
votes
1answer
61 views

Changing stroke width of polygon with categorized symbology using PyQGIS

I have a polygon layer with categorized symbology. I want to change the stroke width of all the categories without touching the categories or colours. Here is the script I have after looking a similar ...
1
vote
0answers
31 views

Raster Calculator in processing scripts crashes using PyQGIS

I am currently writing a processing script for QGIS that goes as follows: Takes in a digital elevation model (DEM) tiff file, a shapefile mask of the study area, and a slope cutoff value in percent ...
0
votes
0answers
42 views

Merging group of point layers with QGIS Python console [closed]

I have two groups of layers as shown in this image, and I want to merge layers of each group separately with a Python script. I have tried the following script but it's not complete I think root = ...
0
votes
1answer
27 views

AttributeError: module 'processing' has no attribute 'runAndLoadResults'

I'm trying to run QGIS standalone app using processing.runAndLoadResults and keep getting this error: AttributeError: module 'processing' has no attribute 'runAndLoadResults' I'm working on MacOS i ...
1
vote
1answer
31 views

Adding new provider to QgsProviderRegistry.instance().providerList() using PyQGIS

I'm trying to get vector layer from arcgisfeatureserver in a standalone app, didn't work, so I checked what providers I got on PyCharm: ['gdal', 'memory', 'mesh_memory', 'ogr', 'vectortile'] While in ...
2
votes
1answer
78 views

Looking for manual on how to properly setup standalone PyQGIS without GUI

My goal is to create a standalone PyQGIS script that is able to run QgsProcessingAlgorithm scripts without GUI. My setup runs on Windows and my IDE of choice is VS Code. I've followed the Windows ...
3
votes
2answers
105 views

Getting the value of OSM tag contained in the 'other_tag' field using PyQGIS

I got my data from OSM and a lot of metadata is stored in field "other_tags", which is in itself an HSTORE key/value field. For instance, my "other_tags" contains a key voltage ...
2
votes
2answers
76 views

PyQGIS outside GUI: module 'qgis.processing' has no attribute 'run'

When trying to use processing.run() from a standalone (no GUI) mode, I get the following error: module 'qgis.processing' has no attribute 'run' in the following trivial example: from qgis import ...
1
vote
1answer
39 views

PyQGIS custom application: no GUI appearing

I'm following the following instructions on getting Python to work with QGIS, outside the QGIS GUI itself: Using PyQGIS in custom applications. But for some reason the GUI is not appearing, yet the ...
2
votes
1answer
83 views

Updating Timestamp values in QGIS

As it is seen in the picture, I have the attributes table which shows the random extracted routes from Istanbul highway map and points on it. Points were uniformly distributed through 2000 random ...
0
votes
1answer
57 views

Copying features from one layer into another in PyQGIS using addFeatures

I am writing a plugin for QGIS 3.8 I have two layers, drop_layer and Fibre Cable. I want to copy all features from the drop_layer and append to Fibre cable layer. I use a function to create ...
2
votes
1answer
32 views

Modifying Timestamps in QGIS

As it is seen in the picture, I have the attributes table which shows the random extracted routes from Istanbul highway map and points on it. Points are uniformly distributed through 2000 random ...
8
votes
1answer
133 views

Selecting layers in group using PyQGIS

This script is applied to all layers on the TOC, and I want to improve it to apply only to layers of a specific group # Create an empty table in memory and add fields newtable = QgsVectorLayer("...
5
votes
1answer
28 views

Disabling automatic selection in QgsMapLayerComboBox

I build a plugin. It has a lot of comboboxes (QgsMapLayerComboBox). They are all empty when no project is loaded. When I open a project in QGIS, a layer is automatically shown in all comboboxes. All ...
0
votes
0answers
41 views

Improve the Python code used to open external files, if any, through the QGIS actions [closed]

Working environment : Windows 10 and QGIS 3.10.14 LTR (standalone old repository) Problem : in a shape file of points, representing signals, the column "Code" of the attributes contains the ...
3
votes
2answers
94 views

Get the bounding box for a QGIS point symbol

I'm looking to do some advanced label blocking for point features, based on the bounds of the symbol, rather than the point itself. It looks like I should be able to derive this from the ...
-1
votes
1answer
31 views

Processing script [closed]

This script runs on only one reference layer and I want it to iterate over all layers in group 1 as a reference layer and name each output layer with the name of its corresponding reference layer and ...
3
votes
1answer
49 views

Developing QGIS plugin: AttributeError: object has no attribute

I was tasked with making a small plugin for QGIS or add a small functionality to an existing one. What I am trying to do is take the "geocode with web service" from the plugin MMQGIS and add ...
3
votes
1answer
29 views

Export Project to DXF dialog using Python

I'm trying to run 'Export Project to DXF' in QGIS using the Python console. The intention is to export multiple vector layers, as defined by a Theme Visibility State, in the same way as if you ...

1
2 3 4 5
127