5

I have several layers that are separated by categories (1-5 being 1 low importance and 5 high importance). Each layer only possesses 1 value.

I merged two layers simply using the Merge Vector function. Now I would like to create a new field which gives me the sum of categories. The final aim is to have an idea of which areas are more important (Those with the higher sum).

(Currently, the 0's in my merged layers are NULL values instead of 0's but I guess I can replace that with a simple xxx is NULL and then update selected features to 0)

**Desired Output**

| Layer A    | Layer B     |       Output |
|:-----------|------------:|:------------:|
|     0      |      2      |      2       |
|     1      |      0      |      1       |
|     1      |      2      |      3       |
|     1      |      0      |      1       |
|     0      |      2      |      2       |
|     0      |      2      |      2       |

How can I make this happen? Should I use Field Calculator?

1 Answer 1

5

You don't necessarily need to merge your vector layers. Your title actually comes close to what you want, which is to perform a union.

Starting with inputs layer a and layer b, both of which have a field value, select Vector > Geoprocessing tools > Union.

For example, here are two overlapping layers, A (blue) and B (red), symbolized by their value field.

overlapping shapes

Here is the output from the union and its attribute table. Note that there are two value fields, one for each input.

union with table

Select the NULLs and set them to 0, as you state in your question. From there, it's as simple as creating a new field via Field Calculator. Simply use the expression "value" + "value_2". Below is the union output, symbolized by the newly calculated sum field:

enter image description here

0

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.