Thursday, 12 October 2017

qgis - 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. It does not buffer at all. But using the (simplified) query as follows does buffer all polygons as intended:



Select id, name, st_buffer(geometry, 100) From mypolygons

Now the issue is, that if I have polygons with a lot of columns I need them to type in all manually. Is there a way to avoid this?



Answer



It does work as intended, and it is only a display issue.


To make is work, just give a name to the buffered geometry and specify this name as being the spatial column.


Otherwise, the virtual layer has two geometry columns, the original geometry and the new st_buffer(geometry) and the 1st one is picked-up for display.


Select *, st_buffer(geometry, 100) as geo2 From mypolygons

enter image description here



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...