I have just started using QGIS (2.12.3) and I need your help.
Overall, I have two polyline shapefiles with the same geometry (the one layer overlaps the other), but the information is stored in a different way. Furthermore, each layer has different attributes. My purpose is to copy specific data from the one layer to other one.
In particular, let's say that I have a layer called F and a layer called M. The layer F is consisted of sets of many lines, whereas the layer M is consisted of sets of a few lines. See what happens when I select the line1 on layer M and what happens when I select the same line on layer F (Image 1).
This occurs because, the corresponding line1 of layer M in layer F, is part of many polylines (Image 2). Therefore, for one entity in layer M, I have many entities in layer F.
The lines in layer F have a field (integer) and my target is to copy each time (e.g. overlapped lines for line1) only the row that contains the minimum value of this field, into the corresponding line in layer M.
For example, if the field of interest in layer F for the line 1 has values 1987 (a), 1802 (b), 167 (c), 2989(d), I would like to join to the line1 of layer M the row of layer F that contains the number 167.
I have tried the spatial join, but this tool takes "the attributes of the first located feature". If there was any possibility to take "the attributes of the min value of a specific field" then it would be the solution, I think. Also, I cannot remove the redundant values because with this way I will lose the correct information for other lines.
Any ideas??
layer
configuration andattributes_dict
. Search for linesegments[key][the_attrib] =
... and replace it withsegments[key][the_attrib] = min(segments[key][the_attrib], line.attribute(the_attrib))
. If you find this a solution worth to consider, I will elaborate and post as an answer.fid
to get the full set of attributes.