I have a Layer with polygons; for each polygon there are different datasets for the last 3 years. Every year some of the data changed, e.g. what was grown on the field, etc. It would be great if I had a tab for every year so I could switch between them and compare them. At the moment it is shown among each other and pretty chaotic.

I can split this dataset in single layers if it helps, so I can either have 1 Layer with all the data or 3 with different data. They all have the same attributes just with other values, only the id for all polygons representing the same area is the same.

The answer is not fitting for me because i have over 900.000 entrys in my attribute table for each year. Besides i want to add data over the years so i need to automate the process. My plan so far was that i can upgrade the database in postgis and just add it as a layer in qgis. I found something close to what i am looking for at irriSAT. I will post a picture here. The red polygons are the entrys i have. For each field i have different data. If i click the polygon i want some kind of tab with the data displayed shown up where i can select the different years. I know this is really specific but that would be perfect.

First picture would be my qgis display (the red outlining doesnt need to be displayed).

Second picture would be the window that opens if i click one of the polygons wich contains data. I dont need any of these fancy graphics just my plain data. It would be great if i could tab or select the year i want to show somewhere in this window

  • Not sure if i understand the problem exactly. But, you could open attribute table of same layer 3 times and in each set the filter for different year. Maybe even better, you can use rule based symbology and labels to display all the data on the map, if you dont have too many attributes ofcourse. – Mat Nov 29 '18 at 21:09

Important: make a backup copy of your layer before beginning.

Before: enter image description here

  1. In this example, we have two years. Select all polygons, copy and paste once, so you have two of each polygon.

    enter image description here

  2. Add a field called "year". Change the "year" value of the polygons so for each area, you have one for each year.

  3. We're going to replace the fields called "crop_2017" and "crop_2018" with a single field called "crop". Use the field calculator to create a new field called "crop" with this expression:

    WHEN "year" = 2017 THEN "crop_2017"
    WHEN "year" = 2018 THEN "crop_2018"

    In the same manner, create a "yield" field.

    WHEN "year" = 2017 THEN "yield_2017"
    WHEN "year" = 2018 THEN "yield_2018"

    enter image description here

  4. Make sure the new field values match the appropriate old field values. Delete the old fields ("crop_2017", "crop_2018", "yield_2017" and "yield_2018").

    enter image description here

  5. Apply a Categorized style using the "year" field.

    enter image description here

In the layer panel, you can toggle which year is displayed on the map.enter image description here

In the attribute table, you can sort and/or filter by year.

  • To sort by year, click on the "year" header.
  • To filter by year, click on "show all features" in the bottom left corner, select "Advanced filter(expression)" and use an expression like "year" = 2017.

If you decide later that you want each year as a separate layer, use the Split Vector Layer tool to split the layer based on the "year" field. The Split Vector Layer tool is in the processing toolbox.

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.