I have a street layer with the correct direction for each line. I want to make a geocoding address based on the direction of lines and hierarchy (highway, main way, alley, etc). For example, in alley 1 i want to create a text like ( alley 1, main street 2, highway 4).Because of line 3 is an alley, this line not included in the address. I want to create this for all of the street lines in a city.

I try to use Feature vertices to point tool Compute start and end points of lines, then join the results and find the hierarchies, but sometimes it did not work.

Is there any ArcMap, Qgis or python solution for my issue?

enter image description here

  • What is the difference between 3 and 4? Why 3 is not in result text?
    – FelixIP
    Commented Jan 30, 2021 at 18:52
  • 1
    Not sure how you code your hierarchy in the attribute table, but this is a workflow I would try: (1) Fetch the start point of each alley, (2) Find the main street which is determined by touches() with the start point, (3) Repeat (1) and (2) between main street and highway as well, (4) Concatenate these fields.
    – Kazuhito
    Commented Feb 6, 2021 at 0:09
  • @Kazuhito. what is touches()? Is it a function in arcpy ? or touche by boundary in select by attribute?
    – BBG_GIS
    Commented Feb 6, 2021 at 10:39
  • I have a column in the attribute table named typeStreet. In this column, i can find street type ( mainstreet, alley etc)
    – BBG_GIS
    Commented Feb 6, 2021 at 10:59
  • Sorry, touches() was QGIS matching expression in the spatial join. Perhaps similar to ArcGIS' Boundary_touches... not so sure about it.
    – Kazuhito
    Commented Feb 6, 2021 at 11:13

1 Answer 1


This is a small example to mimic your case. I have named the layer as 'streets'.

enter image description here

I am using QGIS 3.16.3, which is equiped with overlay_touches() expression in the Field Calculator.

The script is:

if("typeStreet" = 'main street', 
   concat('Alley ', 
          array_to_string(overlay_touches('streets', name, filter:= typeStreet = 'alley')), 
          ', Main street ', 
          ', Highway ',  
          array_to_string(overlay_touches('streets', name, filter:= typeStreet = 'highway'))  
         ) , 

Important part of the script is overlay_touches('streets', name, filter:= typeStreet = 'alley'), which will extract "name" attribute from the 'streets' layer (i.e. own layer) and filter it by the typeStreet. If it is 'alley', it selects the feature fid.1, and 'highway' will be fid.4.

[Logic behind the script]

In this calculation, Main street acts as a hub for the whole alley - main street - highway network. It enables determination of the touching(allay <- main street -> highway) by single command overlay_touches() then use filter to switch between alley/highway. So the calculation starts only if the typeStreet is main street, and ignore other records.

enter image description here

Output will be something like below.

enter image description here

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.