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
3
votes
1answer
57 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
43 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
35 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) ...
1
vote
1answer
50 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
56 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
40 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
52 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
111 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
224 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
47 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
94 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
67 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
75 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
114 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. ...
3
votes
0answers
62 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
131 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
117 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
157 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
221 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
215 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
67 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
25 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
65 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
197 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
0answers
105 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 ...
1
vote
0answers
360 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
648 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
593 views

Keep virtual layer up to date

I have a virtual layer in QGIS 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
194 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
153 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
211 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
129 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
281 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
186 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
123 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
456 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
192 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 ...
5
votes
1answer
459 views

Can't export geometry generator styling to DXF - alternatives?

I've been using QGIS' wonderful geometry generator to dynamically generate root protection zones and crown areas for some tree inventories I've been working on. It's been a massive time saver. ...
1
vote
0answers
85 views

QGIS virtual layer: Linear referencing result with gaps

I have a layer with some roads, and a table, with information of whether the road is paved or unpaved. The table contains linear referencing measurements from (vanpos) - to (totpos). I'm using a ...
5
votes
0answers
97 views

Selecting minimum number of neighbouring polygons required to give a fixed total area

I have a polygon layer. I would like to select the minimum number of neighbouring polygons to give a total area greater than a fixed value. In reality the polygons are land parcels and I would like to ...
4
votes
1answer
623 views

Creating virtual layers using the processing toolbox

A few days ago Cy T posted an interesting question about creating virtual layers using the Python console: Creating new Virtual Layer programmatically in QGIS? Is it also possible to create virtual ...
1
vote
0answers
52 views

QGIS Virtual Layers based on WFS fail to load on re-opening project

I have created virtual layers that use WFS layers as one of their sources. Usually, it is an intersection between the WFS layer and a local polygon layer. I embed all the sources. However, when I ...
2
votes
1answer
406 views

How to save a virtual layer (from a filtered join) with features from original layer in QGIS?

To be specific, I have a shapefile on census block groups (CBGs) in Georgia, but I only want to use those in Atlanta's commuting zone (CZ). However, commuting zone is not a field in the census ...
8
votes
2answers
2k views

Creating new Virtual Layer programmatically in QGIS?

Is it possible to create a Virtual Layer through a python script. For example, I have a layer "road", and I would like to perform sql " SELECT * FROM road WHERE type = 'Expressway' " Will this be ...
1
vote
1answer
159 views

How to get QgsFeatureRequest in a virtual Layer?

I am wondering if/how PyQGIS can intercept the QgsVirtualLayerProvider::getFeatures() requests of a VirtualLayer, and pull out just the spatial extent from the QgsFeatureRequest to dynamically ...
3
votes
1answer
255 views

How to include layer names when union'ing in virtual layers?

I am creating a virtual layer in QGIS using the following statement: SELECT * FROM ( SELECT * FROM a UNION ALL SELECT * FROM b UNION ALL SELECT * FROM c ) AS merged_tables What is the best way to ...
5
votes
1answer
503 views

What spatial functions are available to shapefiles as “virtual layers” in QGIS DB Manager?

Can anyone provide a list of the spatial functions available in the QGIS DB Manager plugin when using shapefiles as Virtual Layers? I've been trying to use things like ST_DWithin and even ST_Buffer ...
3
votes
1answer
1k views

How to update SQL query for a virtual layer?

I created a virtual layer which contains all the geometries and attributes from a shapefile using the following code: vlayer = QgsVectorLayer( "?layer=ogr:path/to/shapefile", "layerName", "virtual" ) ...
5
votes
1answer
438 views

QGIS “Execute SQL” don't accept more than 1 input table

I have some problems using the "Execute SQL" algorithm (in General Vector Tool) in the Processing Toolbox. No problem when I've got only 1 input table, but when I try to select 2 tables as input data ...
3
votes
2answers
456 views

Getting concatenated attribute values from Spatial Join

How can I query polygon features that intersect other polygon features in QGIS? I have ZIP code areas and city areas, and I would like to list all the ZIP codes that intersect the city areas. Example:...