3

In QGIS 2.18.13 I have issues with a normal join of two layers. The first set consists of a large list (n=259102) and I need to pick out 56 objects from this list. For that I have a second list with the 56 object "ID"s which are consistent with an "ID" field in the first list, as is pointed out in Table Join Resulting in NULL.

My first issue was that the two fields containing "ID" was in different formats, so i have tried changing the type in my smaller list using the Field Calculator. The way I did this is just creating a new field with the right type and then copying my "ID" in to that new field, as is suggested in After performing a table join, all the fields are "NULL".

When i try to join these to layers I only get NULL fields in the large list and my objects are not picked out. When i look in the smaller list, my new "ID"s are all NULL as well. This was not the case when I first looked at the attribute table and it seemed to have changed during the join. I have saved the edit before i did the join, so that should not be the issue.

Is this an issue that anyone else has encountered and has a solution to?

1
  • An update on my issue.I have tried doing the calculations on the smaller list and then using "save as" but this also generates null values in the new column with IDs so the issue seems to be with the calculator. Is there any other tools i can use to do this kind of conversion? Commented Dec 8, 2017 at 9:52

1 Answer 1

2

You can achieve that without joining layer, just using QGIS expressions. Use the following expression on the first layer (containing the many points). It creates a boolean value, that you can use in different ways:

  1. Use select by expression to create a selection of those points you defined (in the field object_id) in the second layer.

  2. Create a new field selected with boolean field type.

In both cases, the expression is the same:

 array_contains (
    string_to_array (
        aggregate( 
            layer:='layer_2', 
            aggregate:='concatenate', 
            expression:=to_string (
                "object_id"
            ), 
            concatenator:=','
        )
    ), 
    $id 
)

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.