2

I have two shape files: road layer and a district layer. Is it possible to know which roads belongs to which districts?

I'm currently using QGIS.

1
  • 2
    The concept you are looking for is called "intersection"
    – underdark
    Commented Sep 13, 2014 at 14:37

3 Answers 3

3

In QGIS, you can use the intersect tool (vector>Geoprocessing Tools>Intersect) to overlay the road and district shapefiles to create a new shapefile of roads divided by district.

Alternatively, using the GRASS extension in QGIS, open the vectors in GRASS (you need to open a GRASS Mapset or create a new one, and use the v.in org.qgis command in Grass Tools> Modules List) and then use the v.overlay algorithm (either in Modules List or Processing), which creates another shapefile of roads divided into districts.

2
  • thanks for the reply. What do you mean by make sure each shape files is in the same projection? I tried the intersection but got an empty table.
    – DJJ
    Commented Sep 14, 2014 at 5:57
  • @DJJ I strongly suggest that you read some of the starter materials the QGIS project provides, e.g. this on projections docs.qgis.org/2.2/en/docs/gentle_gis_introduction/…
    – underdark
    Commented Sep 14, 2014 at 8:21
2

This blog led me the answer I was looking for and is really helpful for beginners!

One could join the attributes of two different shape files in qgis by using the following steps:

Vector -> Data Management Tools -> join attributes by location. 

I recommend using the datasets used in the link above to see how things work.

1

I have no idea what you can do in QGIS, but I can describe what I do in ArcGIS.

Technically to be accurate, most polygon on line relationships need a left and right district field to deal with the set of lines that may basically trace the boundary of a district. Lines that are completely interior to the district within a negative buffer are easy to assign a value for both the left and right district fields using a Spatial Join. The lines that remain unassigned I usually examine and assign manually, since imprecise topology is typical and a purely automated assignment does not normally deal with it correctly. Spatial Join never alters geometry, so I consider it the safest tool to use.

I may use the Union tool instead of the Spatial Join tool if I want the roads cut up wherever they cross district boundaries. The Union tool is better than the Intersect tool, because it will preserve all portions of a road, even if it goes outside a district boundary of falls in a polygon boundary gap created by poor topology. Before I do the Union I calculate the original line length into a double field so I can select the set of lines where the length changed, which would be the roads which were split up by the Union tool process. You will find that this can create excessive splits in roads that trace the district boundaries with imprecise topology and still does not handle the left/right assignment on true boundary roads. So I go back to a manual process to reconnect these boundary roads and assign their left/right relationship within the areas of overlapping positive buffers or non-overlapping negative buffers that match the road ROW widths.

It may be possible to use the Integrate tool to achieve a more fully automated approach and establish better topology between the roads and districts. The roads would be given priority to move the district boundaries (assuming the roads have the more accurate topology in most DOTs). Making a backup of both inputs is important with this tool, since it alters the geometry of the source data in both input data sets directly without creating a copy. I usually do not take this approach, since I rarely want to alter feature geometry without manual examinations.

I have just done this process with a ZIP codes layer, a Cities layer, and a state map index grid layer. I took a hybrid approach, because I did not want any splits to occur in any of my original roads and I simply wanted the majority district assigned where a road was really in 2 or more polygon features. So I did a Union and then a pair of Summary Statistics operations that gave me the district that had the maximum line length for each road. The final summary was joined back to the original lines and I calculated the maximum district to the original lines for all roads that were not real boundary roads. I still had to manually deal with actual left/right boundary road assignments for the City and ZIP code layers.

For the state map index grid I did not need to be precise at all, so I did not bother with a left/right assignment and just applied whatever value was captured by the Spatial Join of the grid to the centroid of the road that actually fell on top of the road and calculated that value back to the original road lines.

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.