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
4 votes
2 answers
42 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
3 votes
0 answers
67 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
191 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,196
2 votes
1 answer
85 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
213 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
108 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
34 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
46 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,077
1 vote
0 answers
123 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
30 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
86 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,544
1 vote
0 answers
92 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
3 votes
0 answers
168 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
  • 63.2k
2 votes
0 answers
86 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
  • 950
2 votes
1 answer
635 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,254
0 votes
2 answers
300 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
  • 679
5 votes
1 answer
78 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
97 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
334 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,194
2 votes
1 answer
925 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
138 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
627 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
46 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
2k 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
133 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
  • 456
1 vote
0 answers
212 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,237
2 votes
1 answer
562 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
142 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,033
2 votes
0 answers
96 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,654
5 votes
1 answer
493 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
664 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,533
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
322 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
3k 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,960
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