Questions tagged [virtual-layer]

A QGIS vector layer that is a database view built using SQL over other QGIS layers.

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

Select by Location on Virtual layer works but not on MS SQL Server layer

I have point data within an MS SQL Server. I can add it as a layer to QGIS by creating a DB connection under MS SQL Server and double clicking the table listed. I also have a polygon layer again added ...
James Bourne's user avatar
1 vote
0 answers
32 views

Specifying field type as DateTime when exporting (save feature as...) QGIS virtual layer

To extract useful data from CSV file I use virtual layer. As virtual layer are based on SQLite all field in my virtual layer are of type int, real or text. These data need to be exported in an ESRI ...
J.R's user avatar
  • 15.3k
3 votes
0 answers
37 views

Updating Virtual Layer by PyQGIS

I want to update a virtual layer using PyQGIS by modifying the layer name in the query. Although I have executed the following code, the virtual layer's query remains unchanged when I open the project ...
user234164's user avatar
4 votes
1 answer
76 views

Virtual layers query returning blank layer with ST_intersection

I am trying to create a virtual layer in QGIS that is the intersection of two polygon layers, "Cowardin" and "Wetlands". Both layers are in the map canvas in the same projection (...
Brian Fisher's user avatar
  • 1,071
3 votes
0 answers
45 views

How to use ST_LineMerge or ST_Union to merge lines in QGIS virtual layers

If have an input layer with a couple of lines, called Line with an attribute. I would like to have a virtual layer with alle connecting lines dissolved, regardless of the attribute. input: expected ...
Beni's user avatar
  • 193
2 votes
1 answer
69 views

Save virtual layer for use in another project in QGIS

I created a simple virtual layer in QGIS, combining a couple of points from a polygon layer with vertexes from a polygon layer. I would like to export that virtual layer to be used as dynamic virtual ...
Beni's user avatar
  • 193
2 votes
2 answers
45 views

QGIS & PostGIS STRING_AGG in virtual layer definition returns "no such function: STRING_AGG"

i've defined the following SQL statement in the query editor of qgis' db manager: select sd.fk_polyg, count(sd.fk_polyg), STRING_AGG(DISTINCT sl.typ, ', ') as concat_typ from schaden_stein_detail as ...
robert tuw's user avatar
3 votes
1 answer
88 views

QGIS Speed up slow virtual layer

In QGIS I have a virtual layer which does a line generation based on a point shape. The point shape has about 700 point geometries and 26 attribute fields. SELECT a.Name, a.FromNode, a.ToNode, a....
MtoK's user avatar
  • 61
2 votes
1 answer
55 views

Unexpected behavior when creating Virtual layer using PyQGIS

I have already viewed this link and still having issues - Creating Virtual Layer with PyQGIS. When I create a virtual layer from the Layer -> Add/edit virtual layer and use this as a query it ...
heckubiss's user avatar
2 votes
1 answer
87 views

Is there a SpatiaLite equivalent to PostGIS' ST_DumpPoints? [duplicate]

I've been using PostGIS' ST_DumpPoints to 'explode' multipolygon layer into points with its corresponding polygon part, ring and index information. As QGIS uses a SpatiaLite engine against its Virtual ...
EranGeo's user avatar
  • 1,132
2 votes
1 answer
82 views

Speed up performance of virtual layer based on GeoPackages in QGIS

I am trying to use a virtual layer in QGIS (3.30) to add a region field to a suburb layer, by locating the centroid of the suburb within a region. The general approach is taken from: Spatial join ...
Tom Brennan's user avatar
  • 3,860
3 votes
1 answer
41 views

Get spatial endpoints grouped by attribute via virtual layer

I have a set of lines consisting of several single object LineStrings. These line can be collected to routes by attribute, e.g. a street consisting of multiple lines from crossing to crossing, but ...
e-shirt's user avatar
  • 659
2 votes
1 answer
49 views

Adding a new column with value in a virtual layer query

I've created start and end points from a LineString layer using this answer from another question: select id, sts as route_id, st_endpoint(geometry) as geometry from pointclasstest union select id, ...
e-shirt's user avatar
  • 659
1 vote
1 answer
95 views

Create e virtual layer (points to line) refering to specific rows in attribute table

I have a point layer "Points" with the following attributes: Name FromNode ToNode Startheight Gradient Length Endheight 14870040 14870040 14870055 39 0.005 57.51 14870056 14870056 ...
MtoK's user avatar
  • 61
5 votes
2 answers
180 views

Ordering points when making line in QGIS Virtual Layer

I've got a QGIS point geometry layer with four point features and a numeric field sequence. I want to create a virtual layer joining these points into a line geometry layer (which will have one ...
Spacedman's user avatar
  • 62.6k
3 votes
1 answer
65 views

Creating script to automatically create virtual layers with alphanumeric labels for shapefile grids in QGIS

I have many grids in shapefile format. Adding alphanumeric labels to them can be done through using a virtual layer SQL query as found in this thread: Creating GRID with customized labels in QGIS, ...
Bryce01's user avatar
  • 33
1 vote
0 answers
19 views

Raster pixels to vector points with virtual layer in QGIS

I would like to create vector points for each pixel of a raster that is located in polygon, using a Virtual layer. Details : I have 2 layers: P : vectors layer of polygons R : raster with value in ...
zlikotp's user avatar
  • 14
1 vote
1 answer
90 views

Virtual layer zonal statistic of raster using polygons in QGIS

I would like to create a virtual layer that creates polygons and make some raster zonal statistics in the geometry of these polygons. The aim is to use the polygons geometry to analyze pixel values of ...
zlikotp's user avatar
  • 14
4 votes
2 answers
194 views

Create singlepart polygons with several polygons in virtual layer QGIS

I would like to automatize the creation of several singlepart polygons when polygons (from layer Polygons) are crossed by a the same polyline (from layer polylines), and fill the gap between like ...
zlikotp's user avatar
  • 14
2 votes
2 answers
99 views

QGIS SQL syntax for GeoPackage layer in virtual layer

I'm trying to create a virtual layer in QGIS for use in QField using SQL, but cannot work out what the syntax is to refer to a GeoPackage layer. My GeoPackage is named "survey". My ...
Oisin's user avatar
  • 1,656
0 votes
0 answers
32 views

Create polygons using a loop in virtual layer

I would like create singlepart polygons including polygons from layer Polygons which have the same value in their row unique_number, and fill the spaces in between. It will result several polygons : 1 ...
zlikotp's user avatar
  • 14
1 vote
0 answers
29 views

Is it possible to use zonal histogram or equivelent with virtual layers

I am trying to extract the areas of several land cover classes within a buffer polygon, and want them to change when the underlying polygons are edited. My current work flow is: edit polygon buffer ...
Brian Fisher's user avatar
  • 1,071
0 votes
1 answer
19 views

Partial raster dataset substitution workflow with virtual raster

I have scripted a workflow in ArcGIS Pro where a set of rasters gets some new data for certain areas, which is updated by building a Mosaic Dataset where the new rasters are layed on top of the old ...
MoritzMoreira's user avatar
1 vote
0 answers
62 views

Virtual layer in QGIS from generated geometry by a multi table join

I have a Spatialite database with three tables. I'd like to draw a center point of a line (by using ST_Line_Interpolate_Point) that is generated by a multi table join. The first table has the ...
Pixelfahnder's user avatar
3 votes
3 answers
282 views

Checking overlapping points from different layers in QGIS

I have a map with many layers, each one of them showing multiple points for different cities. For some locations, having the same lat and long data, these points are overlapping, being on top of each ...
Catalin Alexa's user avatar
1 vote
1 answer
58 views

Virtual layer accessing virtual field

I have a layer my_layer containing a virtual field virtual_1. Next step I want to create a virtual layer, which list only unique values (as a bonus also dissolves the geometries by unique values). The ...
gissurfer's user avatar
5 votes
1 answer
201 views

How to create a Virtual Layer using the QGIS Modeler?

At 3.28.4, I am trying to automate a series of manual steps using the Model Designer. One of the manual steps that I would like to automate uses the Layer > Create Layer > Create Virtual Layer ...
Stu Smith's user avatar
  • 8,104
2 votes
1 answer
62 views

QGIS - Let atlas iterate through distinct values of virtual field

I have a CSV-Layer with multiple columns (e.g. ID, owner_name) and well-known text data to contain information about polygons. One ID can be owned by to owners which would cause the feature to appear ...
gissurfer's user avatar
7 votes
2 answers
228 views

How to create a QGIS Virtual Layer that retains the source field types?

In a previous question that I posted, the answer that I accepted involved creating a Virtual Layer from a source layer. The query used to create the Virtual Layer was: select * from my_layer ...
Stu Smith's user avatar
  • 8,104
3 votes
0 answers
82 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
5 votes
1 answer
99 views

Using eval function in Virtual Layer in QGIS

I'm now trying to use the eval() function in a Virtual Layer in QGIS. The version of QGIS is 3.28.4-Firenze, and it contains the SpatiaLite (version 5.0.1) which includes the eval() function as below. ...
Lc_decg's user avatar
  • 137
5 votes
1 answer
146 views

Creating virtual layer with extent of features from multiple layers in QGIS

I am trying to create an atlas that shows a series of plots (polygons) along with the access routes (line features). I need to vary the extent to show the entirety of each site along with the access ...
Brian Fisher's user avatar
  • 1,071
1 vote
1 answer
61 views

QGIS does not find existing column when drawing lines between two point layers

I have two layers containing points. I want to draw lines from each point of layer Quellen to each point of layer Ziele. Layer Quellen has an ID called q.id, Layer Ziele has an ID called z.id. I have ...
e-shirt's user avatar
  • 659
4 votes
1 answer
54 views

Virtual Layer query connection failed at reload project

I have a QGIS project that generates a layer with point geometry from a database (Excel sheet) that I load directly into QGIS. To this table a join is established with a common field of a GPKG point ...
Acperience's user avatar
1 vote
1 answer
197 views

Multi buffer from the virtual layer

I want to write a command that creates a virtual layer for me as a buffer from lines with different distance parameters, for example 5 and 10 km. I want this to be possible in one layer, the geometry ...
Łukasz Maćkiewicz's user avatar
1 vote
0 answers
103 views

Formulating a PostGIS query as data-source for a virtual layer in QGIS

While this seems to be an obvious application of virtual layers, I could not find a full description anywhere how to achieve it: I want to create a virtual layer that contains the results of a ...
larsg's user avatar
  • 11
4 votes
2 answers
224 views

Add text from one layer to polygons in second layer

I have two layers. In first there are points with attributes in the form of text. In the second layer there are polygons. I need to connect the polygons with numbers that are above these polygons into ...
Wojciech K's user avatar
10 votes
2 answers
322 views

Create virtual line layer based on points and connectivity list?

I have two layers: myPoints: a spatial point layer with an attribute field "ID" (entries are unique). connectivityList: a non-spatial attribute table with two fields (idFrom, idTo). Here, ...
jonas's user avatar
  • 105
1 vote
0 answers
83 views

Arrow pathways in QGIS using geometry generator

I’ve been trying to draw trade pathway arrows following the fabulous posts from @underdark for Flow Maps on QGIS from 2019-05-04 (https://anitagraser.com/2019/05/04/flow-maps-in-qgis-no-plugins-needed/...
butter-milk's user avatar
1 vote
1 answer
131 views

Create vector layer/virtual layer with dynamic number of features in QGIS

The problem I want to create a vector layer in QGIS 3.26 with a varying number of features. The number of features should be the same as the number of raster layers open in the project. So if I have ...
Babel's user avatar
  • 67.2k
3 votes
1 answer
125 views

Create virtual layer without geometry from code

I'm trying to create virtual layer to calculate count of features in layer "polygon_layer". I have no problem to create virtual layer from DB Manager. But if I do it in my python plugin, the ...
RainForest's user avatar
  • 1,140
1 vote
1 answer
135 views

@row_number with virtual layer in QGIS

I use a virtual layer that numbering and order features with their ID. Their IDs are previously calculated by using @row_number in the field calculator. So my workflow is to create ID with @row_number,...
zlikotp's user avatar
  • 14
0 votes
1 answer
59 views

Incremented index on polygons using virtual layer in QGIS

I would like to use a virtual layer that numbering a layer of polygons. This numbering should be incremented along another layers of polylines. Example: polyline 1 :start_point = Index : 0 ; ...
zlikotp's user avatar
  • 14
1 vote
1 answer
221 views

Get extent of the current map canvas in a virtual layer query in QGIS

Is it possible to get the extent of the current map canvas in a virtual layer query? Something similar to the variable @map_extent in QGIS expressions that can be used to create a polygon covering the ...
Babel's user avatar
  • 67.2k
3 votes
1 answer
158 views

Snapping to a segment of the point symbol (QGIS)

I have a point layer in QGIS with an attribute field which represents a distance value. My goal is to generate a buffer with this distance value on the fly to which I can snap when creating another ...
MarinT's user avatar
  • 75
2 votes
0 answers
128 views

Clustering points using QGIS expressions or virtual layers

Is there any way of clustering points using QGIS expressions or virtual layers? I need a dynamic solution so I cannot use tools that create static layers and as a requirement I cannot use python. ...
user209491's user avatar
1 vote
1 answer
485 views

How do I select features with the same values but different IDs from a layer's attribute table in QGIS?

I have a multipolygon layer with several regions (green circles) that are identified through numerical fids. Within each region are multiple points (orange dots) with individual pointIDs. See example ...
user avatar
1 vote
0 answers
135 views

SpatiaLite ST_Transform does not return geometry in QGIS virtual layer

I am using the following query to SpatiaLite in a QGIS virtual layer but it is returning null geometries (looking to transform from ESPG:4326/WGS 84 to ESPG:27700/OSGB 1936): SELECT st_transform(p....
George of all trades's user avatar
6 votes
2 answers
948 views

Creating Virtual Layer as union of multiple layers with same schema in QGIS

I have a Layer Group surveyor with lots of layers (shapefiles) with seemingly random names, and with identical schemas. I would like to combine them all to one layer; preferably with a Virtual Layer. ...
Mads Skjern's user avatar
3 votes
2 answers
352 views

Adding a Virtual Layer makes QGIS unresponsive but the test of the query says "No error"

As stated here, I am trying to load a virtual layer from two existing PostGIS tables, using a simple LEFT JOIN statement: SELECT t.id, t.geometry FROM table_t t LEFT JOIN table_f f ON f.fk_poly_id = t....
swiss_knight's user avatar
  • 9,784

1
2 3 4 5