I have a vector layer of about 62km^2. I have a vector layer of roads within that area. How do I calculate the road density (km/km2)? I did a union between the road layer and the area layer, then I calculate the total line length in the area? I'm working in QGIS.

  • 2
    Total length of road / 62km2, what is the problem?
    – nagib
    Dec 3, 2020 at 18:55

2 Answers 2


Assuming that the polygon and road layers cover the same extent, and are projected to the same Coordinate Reference System (that uses feet or meters as the unit of measure), no overlay operation, such as Union, is required. Simply (1) calculate the total road length (feet, miles, km, etc), and (2) calculate the total polygon area, using the same units of measure (square feet, miles, km). Then divide length by area to get road density.


In the menu

Vector > Analysis tools

there's function sum line lengths,

an algorithm that "takes a polygon layer and a line layer and measures the total length of lines and the total number of them that cross each polygon. The resulting layer has the same features as the input polygon layer, but with two additional attributes containing the length and count of the lines across each polygon. The names of these two fields can be configured in the algorithm parameters."

Then you just add an area column with the field calculator and divide the length column by it.

  • Thanks guys! appreciate it
    – Cr K
    Dec 4, 2020 at 17:10

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.