Skip to main content

Questions tagged [qgis-variable]

"In QGIS, you can use variables to store useful recurrent values (e.g. the project’s title, or the user’s full name) that can be used in expressions. Variables can be defined at the application’s global level, project level, layer level, composition level, and composer’s item level." -QGIS User Manual

Filter by
Sorted by
Tagged with
1 vote
1 answer
50 views

QGIS Global Variables Editing

I am trying to clean out some of the variables that I have created over time, but QGIS won't allow me to edit or delete any of the user define Global Variables From the GQIS documentation, it looks ...
Joe G's user avatar
  • 191
5 votes
1 answer
157 views

Accessing layer properties for expression syntax in QGIS Modeler

Overview: In QGIS I want to create a conditional branch in the model designer so that I can pass images with 20m resolution through the 'Warp (reproject)' tool. Images that are already at 10m ...
tds's user avatar
  • 91
7 votes
1 answer
252 views

Working with expressions inside variables in QGIS

This is a follow-up based on the question asked and answered here: (Using attributes tables as variables on QGIS), I named all my layouts according to the "map_code" column + a short for the ...
silf's user avatar
  • 197
9 votes
1 answer
280 views

Using attributes tables as variables in QGIS

I work for a company where we use the same file when starting a project, with all the print layouts already configured, including the names/themes of the maps, since we usually need the same themes. ...
silf's user avatar
  • 197
4 votes
2 answers
101 views

Is there a way to export/import project variables?

I have a project with around 20 variables (for parameterizing font/line sizes, colors, etc. across multiple layers) in the Project Variables table (i.e. in Project>Settings>Variables/Project). I ...
Bob Drzyzgula's user avatar
4 votes
0 answers
111 views

Create a virtual layer with a project variable defining the source layer(s) using QGIS

I would like to create a virtual layer where the source layer can easily be changed by editing the value of a project variable. Something like: SELECT * FROM var('active_layer') I found this post at ...
oekoplaner's user avatar
7 votes
2 answers
286 views

Configuring QGIS Project using external config file

I have a large QGIS project file (let's call it the master project) and would like to use it for several customers. Currently, I am creating copies of the master project for each customer and ...
MartinMap's user avatar
  • 8,338
2 votes
1 answer
132 views

Extract an attribute from a created point and set it as a project variable

I am trying to create a QGIS modeler process by which the center point of the map on the desktop is used to query what County it falls in from a PostgreSQL data base and writes that county name as a ...
Mikeoramma's user avatar
1 vote
1 answer
419 views

Adding variable to print layout using PyQGIS

I have a QGIS workspace (3.26) containing several vector and raster datasets. I plan to produce multiple print layouts from this workspace to display information such as the site location, predicted ...
davehughes87's user avatar
2 votes
1 answer
169 views

QGIS project variable in map composer template file?

I need to insert project variable into map composer file (.qpt) for showing specific legend item. The item is a layer constructed from a URL query that I need to dynamically change based on a project ...
TomyPoty's user avatar
2 votes
0 answers
52 views

QGIS variables as part of the interface

I've recently learned about how to use variables in QGIS. They are, however not that easily accessible as they are for example in Graphical Modeller, where they are part of the interface. Is it ...
Roman Dostál's user avatar
1 vote
0 answers
61 views

QGIS style overwrites layer variable

I set a layer variable with QgsExpressionContextUtils.setLayerVariable(layer, name, value) and then apply a style which is using the value of this variable (a color). But when applying the style with ...
dmjf08's user avatar
  • 1,293
1 vote
0 answers
217 views

Can't set label background nor callouts color to the the variable @symbol_color

Working with QGIS 3.22.8 you can set a data defined override for label color to match that of the associated feature using the variable @symbol_color, but it does not work for label background fill/...
user209491's user avatar
1 vote
0 answers
33 views

Is there a variable for the numerotation of the pages in the layout report workspace of QGIS?

I want to add the page numbers as it is possible with the layout atlas workplace, however I cannot find a similar variable to use in the report.
Lou 's user avatar
  • 11
1 vote
1 answer
108 views

Set font with variable in layout

I'm using QGIS 3.16. I have a variable called Projet_font in my projet. My problem is in the layout composer, it doesn't seem to be possible to use this variable to set the font text? Here is as ...
katagena's user avatar
  • 1,678
1 vote
0 answers
112 views

QGIS layout variables not refreshing when changed

I'm setting up over 100 layouts of different maps. I would like to control extents of layout map from one place, let's say via variable. I tried a way using QGIS global variables but it seems to not ...
mapkowicz's user avatar
4 votes
0 answers
218 views

Variable is not recognize in QGIS expression using overlay_nearest function

Context I use an expression with Geometry Generator in QGIS 3.22 to connect each point with the nearest point that has the value of 2 for the attribute field called value. This works fine using this ...
Babel's user avatar
  • 73.1k
2 votes
0 answers
101 views

QGIS Group Layer Variables

QGIS Group Layers don't have properties, probably because of that there also doesn't exist the possibility to define variables for Group layers. I use Project variables and Layer variables but also ...
geraldo's user avatar
  • 960
2 votes
1 answer
851 views

How can I store a project or global variable that references an object PyQGIS? [closed]

I am working on an expression that creates an object, Specifically, I am creating a connection to a database (cursor), which remains available until it is closed. I need the reference to the object to ...
Luis Perez's user avatar
  • 1,294
0 votes
2 answers
377 views

Indexing from first row of attribute table with Python

I'm just trying to extract the variable value of the 7th column of the first row in a vector layer. I'm not sure how to index the table exactly though. I included the lines I wrote, which I imagine ...
hmnoidk's user avatar
  • 707
5 votes
1 answer
87 views

How variabilizing a part of the name of the data table used by QGIS ? I would like to use the same QGIS project for each year I'm studying

I created a map and a page layout for year 2018: It relies on data of the table temp_desendettement_communes_2018 (from a PostGIS database). I wish using the same QGIS project for other years, and ...
Marc Le Bihan's user avatar
2 votes
1 answer
109 views

Forcing choice for default value during data entry

Let's assume you have to perform different field surveys for different projects. For example, you have to log all sightings of birds for different projects. During data entry of the bird sightings I ...
Sebastiaan B's user avatar
2 votes
1 answer
520 views

Defining an array as a variable in QGIS

I want to use array_first(@myArray) to get the first value of myArray in a data defined box. myArray is defined in the project variables, but I can't find the correct syntax. I tried : (1, 2, 'abc') [...
Leehan's user avatar
  • 1,234
2 votes
1 answer
1k views

How to Access the Current Value of the Scale Factor of a Map as a Variable (eg $map_scale) in Print Layouts in QGIS

Does anybody know how to access the current value of the scale factor of a map as a variable (eg $map_scale) in print layouts in QGIS? I'd love to put the scale factor in my maps...
Axel's user avatar
  • 174
1 vote
1 answer
154 views

Adding different strings to legend title in QGIS layer composer depending on which layer is active

My QGIS project includes three layers representing catchment areas for playgrounds. Depending on the age of the children, the catchment areas are either 200 m (catch_area_200m.shp), 400 m (...
zehpunktbarron's user avatar
1 vote
1 answer
740 views

Is there a way to edit project variables with modeller in QGIS?

Is there some way to set/edit user defined project variables with a model or a calculator so their values can be read by all the layouts and reports in a project? I want to calculate a project ...
Mikeoramma's user avatar
1 vote
0 answers
49 views

Defining variables by selection

I'm working on a valve isolation project for a natural gas application. I'm a design engineer foremost, but like to play with programming and GIS applications fairly often. I've got a bit of ...
Damon Breen's user avatar
1 vote
3 answers
3k views

Using the regexp_substr function in QGIS to get the first letter after white space

I am looking to get the first letter and second letter (after white space) in the QGIS variable @user_full_name to provide me with the initials of the QGIS user that has created a project. For ...
R.B's user avatar
  • 103
1 vote
0 answers
151 views

Set a WMS URL in QGIS using project variables

I would to know if it is possible to set a WMS url in which I would use project variables as parameters? Let's say I have: QGIS project variable : my_variable = some_query WMS url : https://wxs....
M-Rick's user avatar
  • 476
1 vote
0 answers
222 views

QGIS 3.6: variable functions, confusing explanation

The documentation (https://docs.qgis.org/3.4/en/docs/user_manual/working_with_vector/expression.html#id31) says: To use these functions in an expression, they should be preceded by @ character (e....
PieterB's user avatar
  • 5,287
2 votes
1 answer
612 views

QGIS 3 - Variables in rule-based rendering?

I'll try and lay this out clearly, I have most of it covered, but there's a very specific thing I'm looking for in the rules - whether or not it can be done and if so, how? Key things I have done and/...
Fordonian's user avatar
1 vote
1 answer
57 views

Suggestions on how I can depict numerous cell towers with different ranges?

I am trying to make buffers dependent on cell tower ranges. Does anyone have any suggestion on how to insert distance buffers of various that are dependent on attribute values in one layer? I am ...
user avatar
4 votes
0 answers
177 views

How to make QGIS model result to be a variable?

My model's temporary result is a point layer (one feature) and I need a value from one of its fields because I want to use it in the same model to select a feature on another layer. So for example, ...
Skye's user avatar
  • 1,053
2 votes
0 answers
98 views

QgsVariableEditorWidget does not save changes

I would like to edit the variables of a composer item in QGIS 2.18.x. The widget itself is working so far. In my example, I am selecting a QgsComposerLabel called "Plankopf" to show its variables. ...
Thomas B's user avatar
  • 8,876
5 votes
1 answer
571 views

increment column value with an integer when it is a duplicate

I have a layer with around 1000 lines. Some Name are repeated several times and I wish to have every name unique. Thus I try in the field calculator to add an integer at the end of the name only when ...
Nicolas deville's user avatar
6 votes
1 answer
735 views

Getting active PostgreSQL connection's username as variable in QGIS?

Is it possible to get login username from a current PostgreSQL layer connection in QGIS? My goal is to automatically populate new objects in a layer with an editor login username (not @...
Basile's user avatar
  • 3,583
5 votes
1 answer
1k views

Global variables in QGIS mixed on some computers

I create and set some global variables in my QGIS plugin as below: QgsExpressionContextUtils.setGlobalVariable('variable_name', 'some_value') The name is unique and specific, so different from any ...
adamczi's user avatar
  • 739
2 votes
1 answer
366 views

QGIS atlas with chart

I use the the atlas in QGIS for a while, and I use a variable from the atlas to filter labels, construct geometries, etc. But the atlas variables aren't everywhere in QGIS and I can't make a real ...
Matthieu Carlini's user avatar
4 votes
3 answers
4k views

QGIS Query Editor define variable

I am relatively new to QGIS. I use conditional formatting for various problems. In the qgis query editor, I would like to define a string variable for further usage, so I wouldn't have to retype the ...
Krisselack's user avatar
2 votes
0 answers
2k views

On QGIS Composer how to filter the atlas coverage layer using a project variable (rather than just a value)?

A QGIS Composer atlas can be generated from a subset of the coverage layer features using the coverage layer filter control. I can filter for coverage layer features by comparing an attribute of the ...
Rostranimin's user avatar
  • 2,990
7 votes
1 answer
2k views

How to get layer variables using QGIS Python APIs?

How can I access the layer variables defined by the user from QGIS Python APIs?
Kuba Augustynowicz's user avatar
9 votes
2 answers
2k views

QGIS using project variables in filter queries

In QGIS 2.14.11 LTR I have to apply the same (or similiar) filter query to various layers. I have the road name to filter for in a project variable and try to apply the following query: "road_name" = ...
Jochen Schwarze's user avatar