3

I have two shapefiles:

  • a grid containing just the grid "ID" column
  • a shapefile containing multiple entries from different road segments

The second shapefile represents emissions with a common grid "ID" as the one in the first shapefile (grids). This shapefile was a result of an intersection of the grid with the roads as seen below.

enter image description here

This is the attribute table of the first

enter image description here

This is the attribute table of the second shapefile

enter image description here

As seen, there are multiple entries for grid "ID" 229, 230, 231, etc. in the second shapefile.

What I want to achieve is a final grid shapefile such that each grid with a common grid "ID" has the total emissions for that grid.

How can I do this using QGIS?

1
  • 1
    Actually you can do this step when you join attributes by location, you only have to open the tool with the summary sign in front of it from the toolbox.
    – Erik
    Nov 6, 2019 at 9:28

1 Answer 1

1

If you normally access the join attributes by location tool from the Vector Menu, you might not be familiar with the related tool, join attributes by location (summary). This tool is only available through the Processing Toolbox.

Use join attributes by location (summary) to calculate the sum of emission values of all road segments that fall within each grid cell.

enter image description here

6
  • I tried doing this, but I get null values for all grid cells. Do I have to do this with the emission lines that are not intersected with the grid? Or do I first have to intersect the lines with the grid and then do this?
    – meteo_96
    Nov 7, 2019 at 6:54
  • I did the following, but I am not sure if this gives a proper estimation of the emissions per grid: I used the raw emission lines with columns pertaining to the emission line name and the total emissions for that specific line. I followed the instructions here, but instead of using "within" I used "intersect". Would this result in the proper emissions per grid cell?
    – meteo_96
    Nov 7, 2019 at 7:49
  • 1
    You said you already intersected the lines with the grid layer. So the lines should already be cut up so that each line segment is inside one (and only one) grid cell.
    – csk
    Nov 8, 2019 at 16:55
  • 1
    The sum calculation will add together all of the attribute values for the lines in each grid cell. Select the "emission_share" attribute if that's the one you want to sum.
    – csk
    Nov 8, 2019 at 16:56
  • 1
    I've uploaded the files here [drive.google.com/drive/folders/…. Hoping someone could help!
    – meteo_96
    Nov 13, 2019 at 1:59

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.