2

I have several different shapefiles that I want to combine into one based on the minimum value of each attribute. I found this solution. However, I also want to know which shapefile each minimum value came from.

For example, I have 5 shapefiles with values in each one of 10 attributes. For each attribute, I found the minimum value from one of the 5 shapefiles using the method in the solution above. But I also want to know which of the 5 shapefiles the minimum value came from for each attribute. Is this possible?

cahill_598
  • 51
  • 5
  • Add a column to each with the shapefile name, merge, then find minimum – BERA Dec 17 '20 at 15:55
  • Thank you @BERA for your response. My MERGE shapefile already has a column of the original shapefile names. However, when I try to "Add/Edit Virtual Layer" using the method in the link above, the output layer loses the shapefile names column. Is there any way I can keep this column in the output virtual layer? – cahill_598 Dec 17 '20 at 18:25

1 Answers1

3

I found the answer to my question here.

I use "select" to choose which columns (in this case, "layer") I want to keep:

select layer, min(id), "geometry" from Merged group by attribute

Here, "layer" is a column in my Attribute Table with information about which shapefile each "id" came from.

cahill_598
  • 51
  • 5