TransWikia.com

Merging some polygons when creating Virtual Layer

Geographic Information Systems Asked by David H. J. on February 21, 2021

I have a polygon layer 'lot' containing an attribute "lot_number". Then, I want to create a Virtual Layer that merges some of the lots while keeping others separated, as the diagram shows below.

Specifically, in the virtual layer, I want to merge the lots with "lot_number" 1, 2 and 4 into one polygon, and ones with "lot_number" 5 and 6 into another polygon. How could I do that?

enter image description here

One Answer

I figured this out. First you need to create a new field merged_ID in the lot layer, giving a unique ID to each group of polygons to be merged. The attribute table would look like this:

enter image description here

Then type the following query in the virtual layer creation window:

select st_union(geometry), l.*
from "lot" as l
group by l."merged_ID"

Correct answer by David H. J. on February 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP