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
2answers
44 views

Saving Virtual Raster Layer with Project using QGIS

I have a project that uses multiple DEM tiles to create a Virtual Raster Layer. The Virtual Raster is then used to calculate a Slope and an Aspect layer. I've attempted to save the Project, but when ...
2
votes
0answers
36 views

Grouping points by attributes from field with possibly many values

I have a shapefile "cities" with one unique city_id for each city (geometry polygon, although not relevant here) : city_name ; city_id New-York ; 0001 Paris ; 0002 London ; 0003 And a ...
0
votes
0answers
26 views

How to get geometries from this query

Im struggling with this SQL query, from Measure collected polygons in Geometry Generator, avoiding extra texts from multipart polygons. It used to work OK sometimes in some datasets; throw errors on ...
1
vote
0answers
26 views

QGIS 3: QgsAuxiliaryLayer with virtual layers

I'm using QGIS 3.10.1. I've created virtual layers from an ODBC data source and using the (relatively) new feature "label editing". I was able to show/hide/move labels of a layer. But just after ...
2
votes
1answer
71 views

ST_Distance in Virtual Layer query not working on QGIS on Mac but on Windows

I tried to use solution posted here, but ST_Distance in the Virtual Layer query doesn't work properly in Qgis (v3.2) on Mac, the result is showing blank while the same script is working properly in ...
5
votes
1answer
177 views

QGIS and 1-to-many relationship

I am using QGIS 3.10.0 I am attempting to join a spatial vector layer to a non-spatial layer (CSV). Each polygon on the spatial layer has a unique id attribute. The CSV also has this id attribute ...
2
votes
1answer
39 views

Writing txt file from Virtual Layer

I have a Virtual Table which is a result set for a particular process. select "RECORD_IDENTIFIER", CAST ("UPRN" AS textstring) AS UPRN, "KEY", "WARNING_CODE", "EXCEPTION" from Exceptions ...
3
votes
1answer
60 views

Virtual Layer Symbology in Legend

I am new to QGIS and I'm using QGIS 3.8 on a Windows machine. I'm creating a commuter flow map using a virtual layer similar to the one Anita Graser has created here. When I try to add in a legend all ...
1
vote
1answer
82 views

Extract part of multipolygon that does not intersect with another geometry in Spatialite / QGIS DB manager

I have a point layer (with a buffer value), and a polygon layer (footprint) that intersects the point buffer. Using only SQL in QGIS Virtual Layers (i.e. based on Spatialite), how can I get the ...
9
votes
2answers
245 views

Using RECURSIVE in Virtual Layer

Preface For a while, I was wondering about applying the looping/iterable functions in QGIS's Virtual Layer. There were several cases when the application of a loop would be beneficial and ...
0
votes
0answers
25 views

Using Virtual Raster File Viewer of QGIS?

I have created a virtual file using Build Virtual File functionality of QGIS. Is the file linked strictly to where the raster files are stored or can it be viewed on another computer?
3
votes
2answers
153 views

Creating a virtual layer based on a virtual field for dynamic selection in QGIS 3.4?

Working on a PostGIS database, I would like to send to the print composer the selected features only. I'v tried several methods including working with is_selected() expression but the only way that ...
5
votes
1answer
294 views

Getting the line middle point with SQL in QGIS

Using SQL in a Virtual Layer is it possible to get the midpoint of a line on the line? I have tried Finding middle point (midpoint) of line in QGIS? but got an error I also tried SELECT road, ...
4
votes
1answer
81 views

Using a virtual layer, display polygons based on location of another polygon layer

QGIS 3.4 I have a .gml file of every freehold title in a city outlined red below. I want to create a virtual layer of the freeholds which are contained within the blue-green isochrones. Even if a ...
1
vote
1answer
64 views

Changing SQL syntax in QGIS Virtual Layers

I am experiencing difficulties with SQL syntax in a Virtual Layer. I can do the simplest query form such as: SELECT * FROM mytable and this displays on my canvas. However, if I try to name fields ...
1
vote
2answers
81 views

Wrong result using virtual layer sum with join and group by

I am trying to join the grouped sum of two layers using virutal layers in QGIS 3.2. My query looks like: select nvewi.zone as "Zone-Type", sum(nvewi.bev) as "Inhabitants Isochrones", sum(nvewp.bev) ...
2
votes
1answer
63 views

Merging a legend and a table

I'm using QGIS 3.4 for this, and am creating a map that will see quite a lot of use. It will show plant species, and the area of the plants in question. For this, we have a main "plant" table. This ...
2
votes
2answers
92 views

Selecting lines where start and end points within polygon using Virtual Layer

In QGIS 2.18 project there are several layers, lines and polygons respectively My task is to select all lines when their start and end points are laying within polygons using Virtual Layer, see image ...
1
vote
0answers
71 views

Creating virtual layer or view table from original table using pivot table on QGIS?

I have a table and I need to produce a virtual layer with pivot or crosstable command. Is it possible on QGIS 3.6 or 3.8? My original sql is: select cd_setor, Name, Path_relativo from Fotos order ...
2
votes
1answer
72 views

Merging shapefiles as Virtual Layer in QGIS

In QGIS 3.6.3 I'm trying to create a Virtual Layer obtained by merging 12 shapefiles (with the columns named and ordered in the same way) using the expression SELECT * FROM _January, _February, ...
3
votes
1answer
200 views

Difference between JOIN ON and WHERE in Virtual Layers in QGIS

There is already a question on this topic Difference between SpatialJoin with “…where…” and “join…on…”. However, it is dedicated to PostGIS. Since in the Virtual Layer query window, I cannot simply ...
3
votes
2answers
402 views

Virtual layer functionality does not seem to support memory layers

I have a memory layer loaded in the QGIS virtual layer in the data source manager. I am trying to run a very simple query: select * from layer Here is a snapshot: While this works for the physical ...
1
vote
2answers
65 views

write z-value from polygon layer to point layer in QGIS

I have two layers: 1 polygon layer where the depth of an area is written in the database (as DRVAL1) and and where the depth is exported as a Z-value to the geometry. 1 point layer that I use to plan ...
1
vote
1answer
132 views

Preserving geometry of Union output with Virtual Layer in QGIS 2

There is a polygon layer "Union23" that was created with 'Union' tool. Layer's attribute table includes the following values. My effort is simply to aggregate those polygons by "FLAECHEID" field ...
3
votes
1answer
87 views

Add virtual layer to aggregate feature

newbie here of QGIS here, I was trying to aggregate a feature from a CSV with no geometries. The query is very basic: SELECT "PROV", SUM("POP_2012") AS POP_2012 FROM "municipalities-tuscany" ...
2
votes
1answer
106 views

UNION two LEFT JOINs as Virtual Layer in QGIS

In QGIS 2.18, there are two layers, e.g. "Locations" and "Connections" "Locations" has values Id | Dimension --------------- 1 | 4 2 | 8 3 | 2 "Connections" maintains attributes ...
4
votes
1answer
149 views

Select all columns except geometry using virtual layers

Is it possible to select all columns except geometry using virtual layers in QGIS? For example I have this (simplified) query: Select *, st_buffer(geometry, 100) From mypolygons It does not work. ...
4
votes
0answers
76 views

QGIS Server Adding a virtual layer

All my layers in the qgs-project-file are working fine as WMS-layers, but I only can't provide the virtual layer. The virtual layer is an ODBC-Connection of an Access-Database which contains one ...
1
vote
2answers
158 views

Creating a fixed distance buffer from a virtual layer

First off, i'm trying to learn some python to automate scripts for basic tasks i carry out in QGIS (2.18). Below I create a virtual layer (polyline) using the following script: from qgis.core ...
3
votes
1answer
177 views

Extending a segment in QGIS to check intersection with a polygon

I am trying to find the adress points (red dots) located in front of an obstacle (red polygon). The street is green and the pink line represents the street face (Si). This is what I have so far, but ...
2
votes
2answers
205 views

Calculating point layer values within polygon features in QGIS 2

There are two layers polygon BereichBerechnung with a field "Are_Number" points EW2017 with a field "EWjeAdr" In QGIS with a Virtual Layer, I want to calculate the sum of the field "EWjeAdr" for ...
1
vote
1answer
388 views

Efficient intersect query for virtual layers in QGIS

I have 3 tables/shapes as follows: ADRR (adress points) ADRR_ID | ST_ID (street surface id) | point geometry STREET ST_ID | ST_NAME (street name) | polygon geometry Obstacles ID_OBS | ...
2
votes
1answer
350 views

How to speed up a query in a virtual layer of QGIS?

I'm trying to speed up a query in a virtual layer. I noticed that the query runs at the same time for a partial extension and full extent of the layer shown on the map. So I thought if I filtered the ...
1
vote
1answer
99 views

QGIS Custom Python Function to Return Current Extent QGIS 2.18LTR

Related Question Charts and Graphs that only display features in current extent Trying to write a custom function to return the current view extent. The below code is what I wrote based on the QGIS ...
1
vote
0answers
30 views

Extract ordered point coordinates from polygon layer via Virtual Layer or PostGIS View

I have polygon layer and I need to create table with XY coordinates for each polygon staring from farthest to west (lowest value of X). Now I have Virtual Layer with SELECT ST_DissolvePoints(geometry)...
3
votes
1answer
67 views

How to load polygon layer with single field as virtual layer?

I have a polygon layer with 3 fields (A, B and C). I want to create a copy and add as a virtual layer so I use CREATE VIRTUAL LAYER option but only want the first field. So I use the expression ...
2
votes
0answers
263 views

Unable to show geometry in virtual layer qgis

I'm trying to create a virtual layer starting from a municipality layer and from a table of attributes, both stored in a Postgresql DB. So I've done a join like: *SELECT munic, country_of_origin, ...
0
votes
0answers
126 views

Is it possible to add an atlas variable to the SQL query when creating a virtual layer?

I'm trying to do something like this: select * from table_a inner join table_b on table_b.fid = table_a.id and table_b.code = @atlas_featureid I have tried this using QGIS 2.18.16 and QGIS 3.0 ...
2
votes
0answers
393 views

Clipping Virtual Raster in QGIS 3 [closed]

I have generated a virtual raster out of a large number of tifs but I am only interested in an area so I want to clip it. When I do it, it saves a raster file of several Gb. I would like to clip the ...
1
vote
1answer
910 views

Spatial Query for a Virtual Layer

I would like to use SQL to create a virtual layer in QGIS by clipping information from a large data set using a bounding box around my study area. I have two questions. Is this an efficient way to ...
5
votes
2answers
663 views

Keeping virtual layer up to date

I have a virtual layer in QGIS 2 with a query on a CSV. The CSV gets updated regulary. I need the max/min attributes in the virtual layer to be updated as well. The virtual layer is used as a title in ...
1
vote
1answer
246 views

QGIS: alternative to add/edit virtual layer. With python?

Following a previous question (Select polygons with other polygons layer?), I select some polygons using the query in the answer to create a virtual layer: SELECT greens.* FROM greens, purples WHERE ...
2
votes
1answer
188 views

Query and export a grouped subset of fields from a shapefile layer

I have several shapefile vector layers that I need to query so I can group records and export a subset of fields to go into an excel spreadsheet. I thought I could do this by using the graphical ...
2
votes
2answers
257 views

Getting nearest line to point with virtual layer using QGIS?

I have a streetmap and the position of hundred sensorlocations. I am currently trying to calculate the nearest line for each point. I have already done it with the nnjoin plugin. But now I want to do ...
1
vote
1answer
139 views

How to iterate nearest polygons until threshold is reached?

I have a point layer and a polygon layer (representing buildings). I created a buffer around the points and extracted those polygons which intersect the buffer. The points contain an attribute with ...
3
votes
0answers
345 views

Virtual layer from query with special characters in field name using PyQGIS

I have a layer loaded from a WFS server that contains fields with æøå in some of the names. I am making SQL queries to make virtual layers from this layer, but whenever I query a field with æøå in its ...
2
votes
0answers
232 views

Virtual Layers Clipping and Large Data Sets in QGIS

When working with large vector data sets in QGIS is there a method where you can ask QGIS to only load a small subset of your data? I know that this can be done based on attributes using a virtual ...
3
votes
0answers
146 views

Identify Results form for virtual layers in QGIS keeps displaying wrong feature

When I load up a virtual layer and I use the Identify Results tool, it will display the correct information in the Identify Results panel, but in the feature form popup it will always display only the ...
7
votes
2answers
609 views

In QGIS is it possible to apply an expression to a join

I am trying to join by 2 text fields and there is a lot of mismatch due to CaSe and space issues... can it be run so that it's lower("field1")=lower("field2") I otherwise have to create a new field ...
2
votes
0answers
217 views

Using WFS layers in Virtual Layer crashing/too slow QGIS

I am trying to create a virtual layer with the following code, where the layers are provided by a WFS: select geometry from ( select geometry from "Ancient Woodlands (England)" union all select ...