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
0answers
20 views

Data type gets converted from “qlonglong” to “int” when creating Virtual Layer

I have a source layer with ID column as qlonglong. When I execute a query in DB Manager the types seems correctly preserved. The problem is that if I "Load as New Layer" the resulting ...
0
votes
0answers
26 views

Virtual layer with st_buffer from geopackage layer

I'm trying to make a virtual layer that has a buffer over a layer of lines. If I run the following query on a layer in shapefile it works correctly create view river as select st_buffer(geometry,50) ...
2
votes
1answer
80 views

QGIS: no geometry in virtual layer

In QGIS 3.12.2. I created a virtual layer to use for the sort-order in a print layout as described here: Sort attribute table by hidden column in Print Composer That works, but I have a problem with ...
5
votes
2answers
248 views

How to toggle editing on a virtual layer?

When I'm adding a virtual layer to a project using QGIS 3.12.2, it cannot be toggled to edit mode. That is: the pencil icon is greyed colored. This can be said for layers created either by the Create ...
2
votes
2answers
81 views

Saving Virtual Layer to temporary layer

I like the idea of Virtual Layers, but when they are too big and constructed from complex queries, QGIS takes a lot of time to redraw it (it seems like it recalculates the entire layer at every zoom/...
2
votes
0answers
34 views

Extract Geometry information from NMEA GGA sentence in SQLite database for display in QGIS via a Virtual Layer

I have a SQLite database containing a GGA sentence in one of its fields. I'd like to display this information as a POINT layer. I've looked at OGR Virtual Format solution as suggested here but I ...
0
votes
0answers
26 views

Removing lines that don't follow another

I have two line layers, the blue and the pink. I've already modified the pink one by snapping to the blue (i.e. there are pink lines that match the blue underneath), however now I want to get rid of ...
1
vote
2answers
104 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
48 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
32 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
38 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
81 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
254 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
44 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
73 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
121 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
271 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
26 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
249 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
406 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
92 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
82 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
98 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
71 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
119 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
82 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
94 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
303 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
518 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 ...
2
votes
2answers
90 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
170 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
107 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
141 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
168 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
88 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
178 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
215 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
263 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
491 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
469 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
126 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
32 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
71 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
306 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, ...
1
vote
2answers
153 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
420 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
1k 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
714 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
283 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
205 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 ...