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?

2
  • 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?
    – H. Cahill
    Dec 17 '20 at 18:25
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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