I have a shapefile with lines (a road network) and I want to intersect it over a polygon layer in order to finally have a polygon layer (each cell has an ID number) with the intersected lines for each ID.

The shapefile with lines has pollutant emission values (CO etc) (in grams). Before the intersection I calculate a new value (value/$length). See the image (for the selected line CO=6662940.61gr): enter image description here

In the intersected file, in order to calculate the new total value C (in grams) for each grid cell, I sum up the values e.g. CO of each grid cell and multiply with the new length containing in each grid cell. The final result is not correct. I get a higher or lower value in the intersected file comparing to the original one. See the following images For the corresponding line (within two grid cells) I get CO=1568950+4724202=6293153.12gr): enter image description here enter image description here

For the whole grid the difference is much higher, I get almost the double values for the intersected file.

I do the following: enter image description here

Any idea of what could be wrong? Is it right to perform this kind of intersection when working with lines or not?

  • To be honest I don't really get what you are trying to achieve. Do you want to add the attributes of your lines to the polygons? Vice versa?
    – Erik
    May 27, 2019 at 9:06
  • @Erik yes, I want to add the attributes of lines to the polygons.
    – nat
    May 27, 2019 at 9:09
  • Attributes of the whole lines, or only of the part within the corresponding polygon?
    – Erik
    May 27, 2019 at 9:24
  • Only the part of the corresponding polygon.That 's why I did the intersection, but I am not sure if this is the correct way
    – nat
    May 27, 2019 at 9:33
  • 1
    I think the intersection doesn't work fine with line. May be can you try to convert your new lines to points May 27, 2019 at 10:08

2 Answers 2


My approach would be to

  1. transform the grid from polygons to lines
  2. Split the roads using the newly created line-grid
  3. recalculate all relevant data on the split roads-layer
  4. use the aggregate-function in the fieldcalculator on the ploygon-layer to sum all relevant data

Or you could

  1. transform the grid from polygons to lines
  2. split the roads using the newly created line-grid
  3. join the attributes, including an ID, from the polygons to the split roads
  4. dissolve the split roads using the ID from the polygons
  5. recalculate all relevant data
  6. join the attributes of the dissolved roads to the polygon-layer.
  • Thank you @Erik , I will try this. But how I could split the roads using the line-grid? I tried the intersection tool but it didn't work. Also I tried the intersection lines tool but i got only points.
    – nat
    May 27, 2019 at 10:40
  • In the toolbox just search for split lines and choose the Saga-tool split lines with lines.
    – Erik
    May 27, 2019 at 11:08
  • I am trying the second solution you suggested and I have stuck in the 3rd point. When using splitting lines with lines tool it does not keep the ID from polygon grid so I have to join the attributes using the JOIN ATTRIBUTES by Location. However , it gets an error for invalid geometry feature and suggests to change the settings by selecting "Ignore invalid input features" . I can't find anywhere the latter. Is it correct the way I am trying to join the attributes?
    – nat
    May 28, 2019 at 6:35
  • Are you trying to join the polygons attributes, or the line-grid attributes to the split lines?
    – Erik
    May 28, 2019 at 6:46
  • I am trying to join the polygon grid, not the line-grid by selecting "within".
    – nat
    May 28, 2019 at 6:47

On the exemple you show us it seems that the original line intersects with 3 grid cells, not only 2. Am I wrong ? It could be the origin of the error. Check if there is another OBJECTID_1=34434 in your INTERSECT layer.

Another thing bothers me. The two new lines we see have the same length. Have you recalculate the length after intersecting ?

Besides be careful when calculating the new value. You have to go for sum(CO_linear*length) and not sum(CO_linear)*sum(length).

  • No, In zoom it seems that there are only two cells. Anyway, the total result i.e. CO emissions for the whole grid are double than the original file. Yes, I recalculate the new length for each new intersected line..and then I multiply this value for the interected CO_m value
    – nat
    May 27, 2019 at 9:36

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.