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
33 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 ...
  • 45.1k
3 votes
1 answer
42 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 ...
1 vote
1 answer
29 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,...
  • 760
0 votes
1 answer
38 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 ; ...
  • 760
1 vote
1 answer
56 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 ...
  • 45.1k
3 votes
1 answer
94 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 ...
  • 45
1 vote
0 answers
33 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. ...
1 vote
1 answer
50 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 ...
  • 33
1 vote
0 answers
46 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....
6 votes
2 answers
285 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. ...
3 votes
0 answers
100 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....
  • 7,083
2 votes
1 answer
166 views

QGIS virtual layer: Query preparation error on PRAGMA table_info(_tview): no such column: t.poly

I am trying to load a virtual layer from two existing PostGIS tables, using a simple LEFT JOIN statement: SELECT t.id, t.poly FROM table_t t LEFT JOIN table_f f ON f.fk_poly_id = t.id WHERE fk_i_id = ...
  • 7,083
3 votes
1 answer
53 views

Is there non spatial Virtual Layer in QGIS?

I have two users working on the same project with identical shapefiles but in a different geographic area. User 1 is working in Area 1 User 2 is working on Area 2 When using MapInfo I used to keep ...
  • 175
1 vote
1 answer
34 views

Reviewing query from which Virtual Layer was originated in QGIS

I created a Virtual Layer by going in Layer > Add Layer > Add or Edit Virtual Layer. This new layer was created by building a query on another layer I had in my project. Ho can I check, ...
3 votes
2 answers
154 views

Merging/Dissolving multiple layers in QGIS Virtual Layer

I have several polygon layers that I would like to merge and dissolve within a virtual layer in QGIS. So that any changes made to the individual layers will automatically update in the merged/...
  • 33
2 votes
1 answer
56 views

QGIS use "Move feature" for two layers with different geometry at once with attribute tables intact

I have 2 layers, which are placed separately, but they create the schematic. Hence their cooperation is highly essential. I've styled them in order to match the schematic requirements. Now I have the ...
  • 3,531
4 votes
1 answer
85 views

Grouping lines by name and determining their proportions using Virtual Layer

I have a line layer with hiking trails. The hiking trails are divided into their surfaces. So one hiking trail consist of parts with different surfaces. I would like to use a virtual layer to group ...
  • 7,777
2 votes
2 answers
66 views

Connecting points by line number and code in QGIS

I am looking to connect points with a line using Geometry Generator or Virtual layer. Each point has a unique number, a code and a line number. The goal is to display in QField application the lines ...
  • 21
0 votes
1 answer
138 views

Query SQL x Virtual Layer x Joined Fields

I am facing the following situation. I have a spatial layer which I did a JOIN tool with a data table. Now in my attributes window I see all the fields: the original ones and the ones from the joined ...
1 vote
0 answers
42 views

How to select nearest feature with the same attribute on different layer in QGIS?

Introduction: I have two point data sets containing data about sites investigated using different methods, let's call them sites-original and sites-comparison. Each table has a field "method"...
  • 1,528
5 votes
1 answer
68 views

Dynamic closest point with subgroups in unique layer in QGIS

I work in forest and I need to export plans for students. They have to designate some trees on field (a forest plot with all trees numbered) and I get a CSV list with the student's number, the tree's ...
  • 1,035
5 votes
2 answers
436 views

Joining multiple layers in QGIS

I have about 25 GeoPackage files, each containing a table with an "ID" field and another with density information about that area. I want to join all those density information into one layer,...
4 votes
1 answer
149 views

How to deal with removing/disabling a virtual layer that makes QGIS unresponsive

I created a virtual layer and wrote an expression that I suspect was really heavy and returns a very large data set (I was playing around). After adding the virtual layer QGIS became unresponsive and ...
2 votes
1 answer
54 views

Automatically update Buffer Layer

I have recently started working with QGIS. Quite new to this software. Anyway, my first task is to create contours from shapefiles using buffers, unions and dissolve functions. This shapefiles are ...
4 votes
3 answers
194 views

Creating difference of two polygon layers using Virtual layer in QGIS

I am trying to learn the usage of Virtual Layers in QGIS but I can't find a solution for a problem that seems very simple. I have two polygon layers and I want to have the difference. Polygon layer 1: ...
2 votes
0 answers
135 views

How to Multipart to Singlepart a QGIS virtual-layer?

I have a polygon layer I want to explode into single lines. I preferably wish to do so in spatialite since I work almost exclusively in QGIS DB-manager. No matter which function I use the number of ...
  • 944
2 votes
1 answer
152 views

Calculating the angle of view from points to a polygon

This question Calculate field of view / angle of a point to a shapefile was attempting to achieve a similar outcome to my need (calculating the angle of view between observer locations and a polygon). ...
1 vote
1 answer
220 views

Aggregating point geometries and creating envelope using Virtual layer in QGIS

I am trying to group points using a Virtual layer and create a rectangle covering an extents but I cannot get it to return the geometry. Current code is this: SELECT VP.Page, st_envelope(...
1 vote
0 answers
36 views

How do I aggregate grouped point geometries with a fixed point in a virtual layer?

I am creating an atlas for viewpoints (point layer) looking toward a site (polygon layer, one feature only). Each page of the atlas must show the site and either 1 or 2 of the viewpoints. The ...
5 votes
1 answer
159 views

Creating Single sided buffer with Virtual layer in QGIS

I'm creating a layer with single sided buffers based on a line layer as virtual layer in QGIS with the following query: SELECT id, ST_SingleSidedBuffer(layer.geometry, layer.buffer_dist, layer....
  • 185
7 votes
2 answers
121 views

Creating subset of layer intersecting with BBOX of certain features of the same layer using Virtual Layer in QGIS

I'm trying to create a subset of one layer which includes the geometries intersecting with the bbox of certain features of the same layer. I tried to create a Virtual Layer in QGIS with the following ...
  • 185
4 votes
1 answer
144 views

"Duplicate column name" error when calculating length of shared boundaries between multiple polygons using Virtual Layer in QGIS

Similarly to the poster from this question, I am trying to calculate the length of the boundaries between several polygons. I have two types of polygons (1:blue and 2:pink), but I don't think that ...
6 votes
2 answers
415 views

Intersecting more than two layers at same time using QGIS

Background: At 3.20.3, there are two intersect tools available: Vector > Geoprocessing tools > Intersection and Processing Toolbox > SAGA > Features - Polygons > Intersect. In both ...
  • 7,110
5 votes
1 answer
257 views

Creating integer and string fields in attribute table

I am trying to create a new attribute field "FromNode" in a layer that contains string with an integer. EXAMPLE: name1, name2, name3, name4, ... till the end of the table. I got the ...
2 votes
1 answer
117 views

Joining hub and spoke points by lines using Virtual Layer

I have two shape points as shown in image below. Point 1 represents the connectivity nodes (hub) Point 2 shows the address(spoke) How to connect each hub (connectivity nodes) to nearest spoke(...
  • 835
2 votes
0 answers
95 views

Virtual layers w/ spatial query not working as before (3.18.1 vs 3.20.3)

I have a set of maps that intensively utilizes virtual layers, but last week our boss updated from QGis 3.10/3.18 to 3.20.3 in all PCs, and now the layers are not loading. Normally they would refresh ...
  • 343
2 votes
0 answers
87 views

Distance between line and point with shared ID

I have a point layer and a line layer with matching ID fields. I want to calculate the shortest distance between points and lines where the ID matches. They are not always the closest features to each ...
  • 438
1 vote
0 answers
36 views

QGIS Dynamic Virtual Layer as layer coverage of Atlas

Trying to optimize QGIS for my work, I tried to setup a dynamic virtual layer as a layer coverage of my atlas composition, using DB Manager. I join a vector file to a txt file to use one polygon as my ...
4 votes
1 answer
167 views

Selecting all features from two polygon layers in one Virtual Layer in QGIS

I have two polygon layers that partially overlap: buidings and plots. Each layer has 126 features. I want to create a Virtual Layer that is simply an addition of the two layers, thus it should contain ...
  • 45.1k
3 votes
1 answer
57 views

Length of shared borders between polygons using Virtual Layers

I have a map with many counties, and I estimated the length of the common borders using one of the answers from this question posted a year ago. The properties of my layer look like this: I did the ...
  • 33
2 votes
1 answer
60 views

Queries for subset sub-setted data spatially in Virtual Layer

I need to fiddle together some small but smart queries in a Virtual Layer. I have a growing GPKG of field observations, and for easier analysis of the progress, I would like to create some queries in ...
  • 3,097
2 votes
1 answer
70 views

Query for calculating length of lines inside polygon gives empty output [closed]

I am writing an SQL query to calculate the length of lines inside a polygon. SELECT r.*, st_length(st_intersection(r.geometry,b.geometry)) AS Length_Inside FROM Gen_Line as r, Buffered as b WHERE ...
0 votes
1 answer
94 views

ST_azimuth creates only NULL values for Virtual Layer in QGIS

I have two layers with points representing two measurements of the same structure using two different methods. The points representing the same structure element have the same ID in both layer. To ...
  • 1,528
3 votes
1 answer
82 views

Polygon to Lines in Virtual Layer

Is there a way in QGIS to transform a Polygon layer (shapefile) to a Line layer through "Virtual Layers"? In case there is how could I in addition to making the conversion also avoid ...
  • 1,064
3 votes
2 answers
430 views

Area of each polygon that intersects another layer and total area of intersections in QGIS

I have two layers: 'A' (orange) and 'B' (purple). Using a Virtual Layer and group_concat I am able to list the polygons in layer 'B' that intersect with those in layer 'A' thanks to @Jesse McMillan's ...
  • 99
5 votes
1 answer
181 views

Disjoint is very slow in Virtual Layer but fast on symbology

In QGIS, take a polygon grid (named 'grid') and a multipolygon layer (named 'surfaces'). For each feature in surfaces, I want to union all features of the grid that are disjoint (not intersected) with....
  • 1,035
0 votes
0 answers
134 views

Creating virtual layers using Python and export them without using QGIS UI

I am trying to create a flow map and have 5000 nodes and millions of edges. I've used SELECT StartID, DestID, Weight, make_line(a.geometry, b.geometry) FROM edges JOIN nodes a ON edges.StartID ...
  • 571
5 votes
3 answers
438 views

Calculating overlap area that belong to each point in QGIS

I want to calculate the overlap area of buffered points in QGIS. I have tried 'Polygon self-intersection' of the buffered points, but there is only 1 overlap area for each overlap. For example in the ...
  • 61
1 vote
1 answer
130 views

Create geometries from data-only tables using virtual layers

In QGIS 3.18, I have two data-only layers (csv) - the table coordinates containing lat/lon values, the table data containing attribute data. Both tables have a common unique id: 1 (data) : n (...
  • 45.1k
3 votes
2 answers
301 views

Counting points in each polygon so that points do not repeat QGIS

I have a points layer and a polygon layer. I need to count points in each polygon/buffer so that points do not repeat. For instance, here is an example with 4 polygons and 8 points inside in total. ...
  • 580