2

Currently, I have two attribute tables my vector table and an additional table for vector interaction. I was wondering if I could merge the attribute tables within the software.

As I would like to use the "Delete duplicate geometries" as some of the data would be reoccurring and would like to delete them without manually doing that. Is this possible?

2

2 Answers 2

3

You can merge them by going to:

Vector > Data management tools > Merge vector layers

you can also join two attribute tables in Layer Properties but as mentioned above you'll need a common field between attribute tables.

 properties > join

To eliminate duplicate geometries you can both dissolve the layer by field:

Vector > Geoprocessing tools > Dissolve

or search for Delete duplicate geometries in the Processing toolbox

2

Alternatively, I can suggest using a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer....

Let's assume there are six features in 'LayerA' (there are two features with the same geometry, namely "Name 5") and a CSV file ('data') with some values that we are interested in, see image below. Instead of a CSV file can be a usual shapefile as well.

input

With the following query, it is possible to join "values" from a CSV file.

SELECT
    DISTINCT a.*,
    d."value"
FROM
    "LayerA" AS a
JOIN
    "data" AS d
        ON a."Name" = d."Name"

The SELECT DISTINCT statement is used to return only distinct (different) values.

The output Virtual Layer with its Attribute table including new values will look as following

output


References:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.