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 [qgis-python-console]

Python console embedded in the QGIS GUI, which enables users to use the Python bindings for QGIS (PyQGIS) in order to interact with QGIS objects and functions.

1
vote
0answers
15 views

How to update datasource of handle bad layer with Python console in QGIS 3.4

How do I update the datasource of file project in QGIS, for example myexample.qgz from Python console? What is the command needed, or scripts standalone? For example: layer = iface.activeLayer() ...
0
votes
0answers
41 views

Running PyQGIS script inside QGIS console via Plugin?

I have some calculation and processing done on vector data. I have written code in pyqgis( and executing inside Console).I need to create a plugin (for my use only) which don't have any input button ...
1
vote
1answer
49 views

Extracting raw data from WCS raster using QGIS python console?

I am trying to replicate the following manual workflow in the Python console of QGIS 3.4.7 Manual workflow: 1) Connect to WCS service. Name: USGS National Map Elevation OGC-WCS URL: https://...
1
vote
1answer
60 views

Enable “Render layers in parallel using many CPU cores” from python console QGIS [closed]

How can I enable "Render layers in parallel using many CPU cores" option from QGIS python console?
0
votes
2answers
296 views

Loading vector layer in Python console?

I am trying to load a vector file to QGIS Python console. v_layer = iface.addVectorLayer("G://Consultancy\Data\Transfer\Bodhi (Louis) Gorringe\QGIS\Shapefiles\Biological Shapefiles\Seabirds\At sea ...
1
vote
0answers
83 views

Qgis Python console not working

I have a small problem with the Python console in Qgis. I am working through some code .py but lately the console does not show results, for example I write directly on the cosola print "prueba" ...
2
votes
2answers
85 views

Write to QGIS python console from plugin with sys.stdout

From my own QGIS plugin, I want to print text to the python console (see motivation below). Most simply, I use import sys sys.stdout.write('Outputtext') And get: AttributeError: 'NoneType' ...
1
vote
1answer
81 views

Running python code created in QGIS

I'm using QGIS 3.4 and Python 3.7.0 on Windows 7. From the Python console of QGIS, I created a test script ("test.py") which contains the following line: print('Hello) and this is saved in C:\...
2
votes
2answers
96 views

GIS software that can work only on Ubuntu Terminal? [closed]

Recently, I tried to open a QGIS project on Ubuntu, but I can only use Ubuntu's terminal for that which gives me the following error: QGIS starting in non-interactive mode not supported. You are ...
1
vote
1answer
35 views

Change main properties of map composer from cache to render from Python Console

I'm trying to print out a map from Python console. The issue is that when I add a layer to the map composer, the property of the map is set to cache. However, I want to change it to render so that the ...
3
votes
1answer
68 views

QGIS behaves different when i have the “python console” active compare to not active

I'm developing my QGIS3 plugin and I've realized that if I have the Python console active (so I can see it) the plugin behaves as expected, while if I don't see it doesn't. So this is the code: for ...
3
votes
0answers
48 views

Getting Python console in QGIS to do tab completion of file system?

I am trying to have the Python 3 console tab of QGIS 3 complete my file system. I've tried import sys but this does not allow me to do it.
-1
votes
1answer
35 views

Incorrect parameter value in Python Console in QGIS [closed]

I have a problem with python console.In Figure 1,the only thing I do is to define the 'inputFile' as 'filepath+fname' and 'outputFile' as 'FileSavedPath+fnameSaved'. But apparently there's an error. ...
0
votes
2answers
118 views

How to run the graphic modeler from the python console in QGIS? [closed]

How can I run the graphic modeler from the python console in QGIS?
2
votes
0answers
55 views

Changing the Location of Python Expressions QGIS3

I've recently started using QGIS and I've written a few custom functions to use with expressions in the Function Editor (see image below) From what I can find these appear to be saved in: C:\Users\...
0
votes
1answer
69 views

Enabling 'on the fly' CRS transformation via python console of QGIS?

I am using QGIS 2.18. Is there a way to enable the 'on the fly' transformation project setting from the python console?
1
vote
2answers
124 views

QGIS can't type in python console

I have troubles with python console in QGIS 2.18.23. When I type something like Print ("test ") and I press Enter, nothing happens and nothing is shown in the console. EDIT:System configuration: ...
1
vote
0answers
58 views

passing an URL to owslib in Qgis editor doesn't work properly?

I'm trying to determine the version number of several WFS using the python module owslib. since i need to use this version number in ogr2ogr (and for some reason, python's ogr2ogr only works in Qgis' ...
1
vote
1answer
145 views

python's .replace doesn't work in QGIS' python editor

I am trying to compare some files to a datalist. The datalist's names are all in english letters, while the datafiles have the scandinavian "æ" "ø" "å" letters. an example: the file "Kystnære_måger....
2
votes
0answers
261 views

User friendly list of processing algorithms in the QGIS 3 python console [duplicate]

The QGIS user guide section Using processing algorithms from the console has not yet been updated for QGIS 3 and while a previously answered question will do the trick with some extra work, it is not ...
0
votes
0answers
66 views

QGIS python console: Overlapping letters

In QGIS Python console and Processing toolbox > Script editor, the code letters are overlapping. I have this behavior on two different computers, both with win10 and QGIS 3.0.3. There is something ...
3
votes
1answer
45 views

QGIS attribute data updating by not commiting

I am trying to change the values of an attribute in one of my layers. My code is as follows: from qgis.utils import iface from PyQt4.QtCore import * layer =iface.activeLayer() pr=layer.dataProvider() ...
2
votes
0answers
208 views

to extract data from tif files using QGIS [closed]

I am brand new to GIS. I haven't been able to find the solution online, I think I don't know enough to be searching with the right terminology. I have a number of tif files which I have successfully ...
2
votes
1answer
93 views

When PyQGIS script is run through console layer does not load successfully

I made a small script to save a shapefile to disk. I want to run the script through console. When I run the script through QGIS IDE, it runs successfully. But when I run it through the QGIS Python ...
1
vote
0answers
94 views

Shortcuts for QGIS python console commands

I would like to define a shortcut for "Save" in the python console, is there a way to achieve that ? Is it possible to define shortcuts only for the given context of the python console and make them ...
0
votes
0answers
162 views

QGIS not importing correct IPython version for IPython QGIS console plugin

I am trying to run the Ipython console plugin in QGIS 2.18 After installing the plugin, I tried running it, and got the following error: You need to install IPython 3.1.0 (and then restart QGIS) ...
11
votes
4answers
3k views

Getting QGIS 2.x python code to work in QGIS 3.x? object has no attribute 'legendInterface' problem

The following piece of code works well in QGIS 2.x, however it does not work in QGIS 3.x. myDir = 'd:/work/output_folder/' layers = iface.legendInterface().layers() pipe = QgsRasterPipe() for layer ...
2
votes
1answer
359 views

How to amend Python code to work in QGIS 3?

In another thread, I was given this code to import large numbers of dxfs into QGIS. This code works in QGIS2.18, but they just released QGIS 3.0 and have changed the codes to use a different version ...
2
votes
1answer
432 views

QGIS python Console Error - list index out of range

I have a text file which has the details of many .tif files which have to be converted to a single merged .vrt file in QGIS Python Console. text = "W:/04 Tools/07 MapMaker/workingfiles/text.txt" ...
4
votes
1answer
375 views

Add Column and Populate using the Python Console

I am trying to add a new column to the attribute table and populate the column with a string, using the python console in QGIS. I have done the same but populating the column with an integer (...
2
votes
0answers
103 views

QGIS processing algortihm crashes in python console but works manualy

I am loading two layers from PostGIS database and I am trying to run 'qgis:intersection' algorithm with them. Execution of the algorithm through the python console initially works but crash after 2-3%....
2
votes
2answers
222 views

How do I filter large set of points (481,308) in QGIS attribute table by fixing the extents(Lat Long values)

I have a large set of points (481,308) in single QGIS layer with the attribute table(ID, LAT, LONG,..ETC). But I only need points which fall inside particular area or polygon, I have fixed the extents ...
1
vote
1answer
130 views

Code to print in the Qgis console the values ​of the attribute table that are selected in the shapefile

I found a code that prints all data that a shapefile has in the attribute table in the qgis console. But i wanted to have a code that just printed the data that i select in the shapefile. Can someone ...
1
vote
1answer
195 views

QGIS Python Programming Error - Build Virtual Raster (.vrt file) - Error : Unable to execute algorithm Wrong parameter value : [closed]

I am reading a single row from a text file createvrt_row0.txt. The row is : E:/Sreeraj/Task Global Data CONVERSION/Split/1 deg tiles_Global agri_data/N31E2.tif;E:/Sreeraj/Task Global Data CONVERSION/...
2
votes
1answer
161 views

QGIS Batch process of Clipping Raster by Extents using For loop from Python Console

I am clipping a raster by extents from the python console in QGIS by using the following code : from processing.tools import * general.runalg("gdalogr:cliprasterbyextent","E:/Sreeraj/Task/Split/...
1
vote
1answer
688 views

Getting row, col on click of a pixel on a QGIS map

I want to get the row, col coordinates of a raster I'm viewing in QGIS by clicking on a pixel. I found Displaying row/column of point in raster using QGIS?, which presumably provides hints about how ...
0
votes
2answers
453 views

Qgis: work in pyqgis from an external idle

I'm writing a python script but, at the moment, I do everything from the Qgis python console. Is there a way to write and run a pyqgis script externally from Qgis? I'm using Qgis 2.18 and python 2.7....
2
votes
2answers
1k views

Import a custom function from the python console

I'm trying to import a custom function from the python console, but it return the error: 'QgsExpressionFunction' object is not callable My example function (saved as function.py file in /.qgis2/...
2
votes
1answer
355 views

Raster to Ascii by python console in QGIS?

I'm working on PyQgis. I have to convert a raster file to a file .asc. The classic procedure through the Qgis Menu is: Raster -> Translate (convert format) -> on "Ouput file" select Arc / Info ASCII ...
3
votes
1answer
203 views

Finding lowest elevation point among points common in two vectors for each polygon

I have two shapefiles Administrative boundary Stream extract flow (using r.stream.extract) and Raster DEM file I want to find lowest elevation point in each administrative polygon and this point ...
8
votes
2answers
3k views

Getting layer extent in PyQGIS?

I'm trying to write a processing script using grass r.neighbors algorithm for rasters. When you use the Gui for this algorithm, you can leave the GRASS layer extent field blanc to use the minimal ...
2
votes
1answer
145 views

qgis QgsExpression doesn't work corretly

I have to do a script that adds a field and changes attributes values utilising an expression so i use QgsExpression. When i put a expression in QgsExpression where there is only 'field name' it works ...
3
votes
1answer
326 views

Use the Python console to write layer name in attribute table

The task I would like to solve is to write an individual shapefile's name into a new column of its attribute table for all shapefiles in a given directory. My current - disfunctional - code looks ...
6
votes
3answers
6k views

Deleting variables from the Python Console in a programmatic way?

I often use the Python Console for running some lines of code and I also use some prints for checking the validity of the results. If I run this sample code: a = 2 b = 4 res = a + b print res it ...
4
votes
2answers
118 views

Why are symbols not displaying after adding them via the Python Console?

Steps to reproduce: Create a new project->Add new Shapefile Layer(Polygon)->Click on the newly added Layer->Toggle Editing->Using the 'Add Feature' Tool draw a polygon and save the layer Open the ...
2
votes
1answer
1k views

Calling my Python file from the QGIS Python console?

Situation: I have a Python file called 'Hello.py' and another Python file called 'File1.py'. Hello.py imports File1.py. Hello.py code is: print 'hello people' import File1 File1 File1.py code is: ...
5
votes
1answer
214 views

Snap points to route and calculate relative length from start

Input: Points layer points spread around some route Route layer route where each route link is feature of type Multi Linestring. However it's possible to merge it to single feature layer of type ...
3
votes
1answer
124 views

Selecting new records using values inside previous selected rows in QGIS?

I am trying to create a selection. First, I select records which have Null value in "Status" column ("Status" is NULL"). Then it starts to be a bit tricky. I want to select all the records which have ...
4
votes
1answer
1k views

Failed to open Python console error message

In the past, I was able to open my Python console without any problems on QGIS. However, just recently, I tried to open the Python console on QGIS 2.18.2 (Las Palmas) on my mac, but I get this error ...
1
vote
0answers
30 views

What are object Names of of Python Console ToolBars? [closed]

I have a custom plugin that when loaded it hides all tools and toolbars not specified to load. How ever by doing this it hides all the tools that are present in the python console. Clean Console, Show ...