Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
1answer
27 views

Continuous buffer from individual polygons in QGIS

I have a stream segment for which I am trying to find a buffer around with criteria as 5m of elevation. So for each straight line within a stream segment, I have found buffer (polygon) for it. Now I ...
0
votes
0answers
15 views

Kernel Density Estimation Weighting Factor

I dont understand where is this weighting factor coming from, does it need to be in the quakeLyr in the attribute table named with "mag" or? ##Now, we can run the kernel density estimation algorithm ...
1
vote
0answers
27 views

Output layer doesn't get created [on hold]

Why isn't my heat layer valid and I don't get a .tif in this location (this location exists 100%)? Code below: output = "D:/QGIS_Project_New/heat_map_last.tif" heat = QgsRasterLayer(output, "Heatmap")...
2
votes
1answer
29 views

Central deployment of startup.py in QGIS

In QGIS 3 on Win10 we use a startup.py script for setting up e.g. database connections and a couple of other things, residing in C:\Users\me\AppData\Roaming\QGIS\QGIS3 What we are after is to ...
2
votes
1answer
39 views

Get OGR driver Name for QGIS VectorLayer

Is it possible in the Python script to get the name of the OGR driver (for example, "Esri Shapefile" or "MapInfo File") for the QGIS vector layer? __ QGIS 2.18
2
votes
1answer
62 views

How to use QgsRasterInterface.histogram?

This is really a question of how to better understand QGIS API documentation (C++ or Python) but I'll use this example: How do I use QgsRasterInterface.histogram? I was told in this thread I can use ...
-1
votes
0answers
37 views

Current Tips for Developing Plugins [on hold]

I was taking a look at PyQGIS cookbook, but I'm struggling too much to set up the development environment. Can't understand how to make the remote debugger to work with Eclipse. I wonder how are you ...
-5
votes
0answers
33 views

Making another layer dependent on field values in QGIS? [on hold]

Could you help me to achieve the automation written in point no 5 of this query: Automate filling of attribute table using QGIS?
2
votes
1answer
37 views

Zoom on a PostGIS vector layer in a new project with PyQGIS?

I load into a PostGIS database, 2 shapefiles of the QGIS sample data : alaska.shp storagep.shp with the shell code : shp2pgsql -s 2964 storagep.shp public.storagep > storagep.sql shp2pgsql -s ...
2
votes
0answers
11 views

Performing viewshed analysis from each pixel (now points) in raster and getting JSON out of it using QGIS? [on hold]

My question can be divided in 3 steps and I guess I can answer 1.5 of them already. To perform the viewshed analysis from every single pixel in a raster I will need: A viewshed plugin (which I am ...
1
vote
0answers
18 views

PyQGIS Creating Numpy Array from QByteArray (QgsRasterBlock.data()) and vice versa (QGIS3) [on hold]

I am looking for a way to convert the values contained in a QgsRasterLayer object to a numpy array and vice versa without using any GDAL methods. To obtain the numpy array I go through ...
-1
votes
0answers
25 views

Creating a Geo package layer Qgis-3.2 version [on hold]

how to create a Geo package layer in python Qgis version 3.2? In Qgis vector layer not support the field name more than 10 characters. So, I have to create a layer using geo package its create a ...
0
votes
1answer
22 views

ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2

When running my Python program, the following error came out: ERROR 1: NUMPY driver was compiled against GDAL 2.1, but the current library version is 2.2 What can I do to fix this?
2
votes
0answers
33 views

Loading .qgs and .qpt files in standalone PyQGIS script?

I have a .qgs and .qpt files. And I would like to know if it is possible to use them in a standalone PyQGIS script? I am using QGIS 2.18 and Python 2.7 This is the template that I would like to use. ...
0
votes
0answers
29 views

GeoPackage attribute field [on hold]

How to get GeoPackage layer attribute fields and values in Python Qgis (3.2 version) and then how to rename the attribute field names?
3
votes
1answer
50 views

PyQGIS search and replace text using regex

This is based on Run regexp in PyQGIS script? and Search and Replace text in All Fields in QGIS 3 I am trying to modify the code to allow more complex replacements using regex but am unsure how to ...
-1
votes
0answers
32 views

Change filename of QGIS layer in Python? [on hold]

Is there a simple way to change the filename of a layer while operating in QGIS. (The obvious way is to close the layer, rename the file, and open it again. However, renaming it with a simpler ...
2
votes
0answers
22 views

GDAL processing output to memory in Pyqgis

How do I save GDAL processing output rasters to a temporary layer? Using 'memory:' for vector processes works fine, but I couldn't get it to work for GDAL processes. output_rast = self....
-1
votes
1answer
63 views

Import batch of delimited text [on hold]

I am trying to import around 500 point files in .txt format with comma as delimiter. Format of the text is "ID", "Y", "X". I want to display them (optional) and convert them to shapefiles and then run ...
0
votes
0answers
36 views

Creating memory layer with .png image using PyQGIS?

In Aligning Raster and vector layer using PyQGIS when they do not match?, someone gave a solution for creating a point memory layer to correctly align a raster image with a vector. I am wondering ...
1
vote
0answers
29 views

QGIS 3 Value Relation current_value() not working in custom ui form

I have a custom UI form made with Qt Designer with a couple of dropdown list, so I can easily edit a layer. I use a Value Relation on those fields to filter the displayed data. The problem is the ...
1
vote
1answer
21 views

QgsDxfExport not exporting all features of a layer

I have a simple script to export a layer to a dxf file: layer = iface.activeLayer() dxf = QgsDxfExport() dxfPath = os.path.realpath("C:/abc/test.dxf") extent = QgsRectangle() dxflayers = [] dxflayer ...
2
votes
1answer
46 views

Forcing QgsTask to cancel in QGIS plugin?

I want to force closing Qgis project (QgsTask) in some point NOTE: QgsProject.instance().clear() # NOT WORKING QgsTaskManager().cancelAll() # NOT WORKING QgsTask.cancel() # NOT ...
2
votes
0answers
30 views

Renaming attribute/field names in GeoPackage Layer using PyQGIS? [closed]

I need to rename the attribute field names in a GeoPackage layer by using Python QGIS 3.2.
2
votes
1answer
49 views

Updating features from my active layers in QGIS

I'm trying to write a Python script with QGIS 3.4 but I have troubles when I want to change attributes values from a field. With the code below, new values are calculated and the python console ...
1
vote
1answer
37 views

Processing: QGIS Crash with new processing script format, QGIS 3.6.1

I've just started to use the new (3.6.1) processing script format (see https://github.com/qgis/QGIS-Enhancement-Proposals/issues/134 or https://anitagraser.com/2019/03/02/easy-processing-scripts-...
4
votes
1answer
41 views

Setting layer identifiable, seachable and removable with Python in QGIS 3?

With PyQGIS, I want to set project layer properties (Project Menu > Properties > DataSource) such as Identifiable, Searchable and Required (for Read Only, the method is QgsVectorLayer....
3
votes
0answers
69 views

Canceling task currently running in background using PyQGis?

I am trying to close QgsProject on loading layer (if password and username from QgSProject - datasource are incorrect) before QgsCredentialDialog is shown. on signal : QgsProject.instance()....
1
vote
0answers
15 views

How to return output a raster layer in a custom processing script in Pyqgis

I've written a couple of custom scripts for vector shapefiles by following the template provided in QGIS. I am now trying to write a script which will use gdal algorithms to process layers. I have ...
3
votes
1answer
56 views

Selecting and updating attribute values using Python console in QGIS?

I am working with Landusefc and Class columns (ref table). What I want is: Selecting all water from "Class" and giving a value say '8' in the "Landusefc" column for these selected features. Table ...
1
vote
0answers
22 views

Is it possible to put grid lines with coordinates in a PyQGIS standalone script?

I just want to know is it possible to put gridlines and border with coordinates (lat, lon) in an image in a standalone pyqgis script. I have checked almost all cookbooks about python ang qgis and ...
0
votes
0answers
23 views

Automatic switching between chronological imagery set at 1 month interval in PyQGIS? [on hold]

I have 12 imagery layers of every month in a year. Now I have to manually switch between different image to visualize the permanent/temporary water, grassland changes and cropland changes at that ...
1
vote
1answer
20 views

Defining geometry type in QgsDataSourceUri

There is a PostgreSQL database containing some layers that have few types of geometry (multipolygons and linestrings). I need to distinguish these geometries in two separate layers. My basic strings ...
0
votes
0answers
43 views

Loading shapefile in standalone PyQGIS script? [closed]

I have a standalone pyqgis script that automatically visualizes 4 parameters (precip rate, temperature, pressure and wind). when I run just the precip rate and pressure part of the script there are no ...
1
vote
0answers
78 views

PyQGIS raster image shifted from vector shapefile

I previously asked a question about my raster image being larger and shifted over from my vector image here, but now I realize that the raster image is only shifted to the left and up from the vector ...
0
votes
0answers
23 views

GPS file categorizer

Do you know a software tool that can categorize/group GPS track files based on the location of its points? I need a tool (standalone executable, script or QGIS extension) which I can feed a list of ...
0
votes
0answers
22 views

Rule based style for a custom processing script output in Pyqgis

I have a custom processing script written using the sample template provided in QGIS 3. I just want to ask how to set styles within the code? I found a reference code for rule-based styles here: How ...
2
votes
0answers
31 views

Still a Python27 folder?

Can anybody tell me why there is still a python27 folder along with the python37 folder in the latest (3.x) QGIS releases?
1
vote
1answer
28 views

Referencing a table using PyQt5 on a custom form in QGIS 3

I am currently trying to add logic to a custom form to key out a habitat code. This is for work using UK Habitat Classification. It is based on a 5 level hierarchical code to produce a Primary Code. ...
1
vote
0answers
24 views

Adding attributes to a feature using ChangeAttributeValues in Pyqgis

I have a workareas polygon layer with X number of features and a buffer CSV layer with Y number of entries which looks like the table below (one id field and a couple other fields). id1 | A1 | B1 | ...
1
vote
0answers
36 views

Create buffer based on the size of a line's length (QGIS) [closed]

I need to create a buffer around a point, witch has to be 1.3x bigger than the length of a given line. I want to automate this process with graphical modeler or pyqgis. So the program should ...
3
votes
2answers
118 views

Check if button is pressed in QGIS 3 module

There is a plugin I wrote for QGIS and I added some buttons there. From main launch Python script I need to check is specific button is clicked and according to that do some stuff. I saw a default ...
2
votes
2answers
106 views

Search and Replace text in All Fields in QGIS 3

I want to replace a string in ALL FIELDS / Columns of table without having to do it using field calculator in every field manually using replace( "RoadName1" ,'Wharf','WharfXXX'). I have layer = ...
0
votes
1answer
52 views

Iterating through group to get layer names in PyQGIS? [closed]

Can somebody provide me some source code in PyQGIS 3.4 to iterate through groups and list out the layernames? In the image you see several groups and single layers. The purpose is to build a ...
1
vote
0answers
28 views

Merging multiple QgsRasterLayer objects to create virtual raster (.vrt file) using gdal

I am creating multiple QgsRasterLayer objects in pyqgis and I need to merge them into a virtual raster .vrt file which will eventually be loaded as a layer in QGIS. The QgsRasterLayer objects are ...
1
vote
0answers
43 views

QGIS Field Calculator update existing field using python console

How do I update existing field with a common number using Field Calculator Python console in QGIS 2.18.10? I have tried: processing.runalg('qgis:fieldcalculator', layername, "fieldname", 2, 20, 0, ...
1
vote
0answers
54 views

PyQGIS overlaying raster image on vector map correctly?

I have some code written in Python using PyQGIS where I am trying to overlay a raster image gridded with coordinates on to a vector shapefile map with the same coordinates. However, when overlaying ...
2
votes
1answer
54 views

Creating an Action in QGIS with multiple Expression?

I want to create an action in QGIS with multiple Expression. But unable to do so. I want to open images from two different directories with one action. Is it possible? How can I do so? e.g. Type : ...
0
votes
0answers
28 views

Request WFS data using GeoServer's viewparams with PyQGIS?

Using PyQGIS how can I request WFS data using GeoServer's viewparams request parameter? I can use the viewparams request parameter to obtain the filtered WFS data I require via my web browser but not ...
2
votes
1answer
30 views

Converting QgsRaster object to array

So I'm a newbie, so sorry if this is an idiot question. I'm trying to write a plugin for QGIS3 for my organisation, and I'd like to output a standalone figure (i.e. not in the QGIS window) as the ...