Questions tagged [pyqgis]

Use for the python library that applies to the Qgis GIS program.

Python bindings for the Qgis GIS program. Example code and descriptions can be found at https://docs.qgis.org/3.10/en/docs/pyqgis_developer_cookbook/index.html

170 questions
0
votes
0 answers

Export XLSX from custom python plugin for qgis

With this code included in custom plugin for QGIS I write on a csv file all the layer features and for each feature I do some actions. line1 = ';'.join(name for name in…
0
votes
1 answer

How do I create a menu that execute .py codes from a python diectory dynamically?

I'm new here , and i have a problem in pyqgis 3.16. I want to make a menu list that every time you click its run a .py file (fuction runf) But i want to create by a list of a files in the directory and i need to the code to read every file in the…
0
votes
0 answers

Setting up QGIS-related .bat files for standalone Python script in PyCharm - errors

I have been trying alot of different solutions for the problem, but keep getting the same error. And it seems that Python is perhaps looking into the "wrong" python directory - or something. However, I have been following the stated in…
0
votes
1 answer

Tracking method for QGIS Plugin Usage

I have a QGIS3 python plugin that I would like to track its users' usage. Is it possible to add a http request to the headers? How can I do it?
ManuCiao
  • 121
  • 1
  • 3
0
votes
2 answers

PyQGIS: change expression for datadefined symbology

I have a QGIS project that displays calculation results on a map. There are several vector layers, each with >100 calculated fields. The way the data should be visualised is very similar for all these layers/fields. I try to write a script that…
0
votes
0 answers

Open Street Map map export

How to export country map, not only lines, polygons and points, but with roads, streets, etc. Tried to download this one http://download.geofabrik.de/europe/ukraine.html, but it consists only of points, lines, multipolygons.
0
votes
2 answers

Segmentation Fault after creating PyQGIS standalone application the second time even after exitQgis() - Debian

I am trying to create several .qgs project files to be served at a later time by an instance of qgis Server. To this end I need to start a new PyQGIS application several times upon request. The application runs smoothly the first time it is called,…
f4_basito
  • 1
  • 2
0
votes
1 answer

PyQGIS: UPDATE, INSERT before SELECT

I can run a SQL in a PostGIS Table to load the query in QGIS3.16 (running Ubuntu Desktop 20.04) like this: uri = QgsDataSourceUri() uri.setConnection("localhost", "5432", "dbname", "username", "password") print("Connection Successful") nb =…
HelpOverFlow
  • 315
  • 1
  • 2
  • 10
0
votes
1 answer

Error inserting polygon using Python Console in Qgis GIS software

I just started using Python Console in Qgis GIS software. I want to add a polygon using the Python Console that exists in Qgis. I tried to combine the codes I found from a few documents. feat.setGeometry(QgsGeometry.fromPolygonXY([points]) The above…
emre
  • 9
0
votes
0 answers

Why does Python's None value not seem to be triggering my conditionals?

I have a Python script running inside QGIS. It looks like this: class Ranker(object): @staticmethod def haversine(lon1, lat1, lon2, lat2): """ Calculate the great circle distance between two points on the earth…
0
votes
1 answer

PYQgis - add border to legend

I would just like to add a black border of 1mm to my legend generated with PYQgis. Like this (with QGis): How can I do ? Here is my code : # LEGENDE legend = QgsLayoutItemLegend(layout) # STYLE LEGENDE…
Préliator
  • 71
  • 3
0
votes
1 answer

PyQgis update layers of canvas freezes application

I'm trying to update layer of a QgsProject instance with a timer in a new thread and show the updated data in a QMainWindow. But however I change the attributes/features/layers, it always freezes the application. I understand that the QgisProject…
0
votes
1 answer

partially initialized module 'json' has no attribute 'loads' - not naming problem

i'm getting AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to a circular import), i searched a lot on google an nothing worked. I don't have any module called json or something like that so that's not…
Micha
  • 93
  • 1
  • 7
0
votes
1 answer

List all raster layers in Geopackage using pyqgis

With the following code it is super easy to list all vector layers in a geopackage: my_gpkg = r'PATH_TO_GEOPACKAGE' gpkg_layers = [l.GetName() for l in ogr.Open(my_gpkg )] Is there also a way to list all raster layers in a geopackage?
0
votes
2 answers

INSEE API Module not found in PyQGIS

I'm a beginner in programming. I made a script that allows me to create and export maps in a full automatize way in PyQGIS. My goal here with this API, is to add some data with the "siret" number on each maps. But even before I could try to do that,…
Nathan25
  • 1
  • 1