I have 2 layers, one representing streets, and one representing pipes. The pipe layer has a street field that I want it to be automatically filled (I want the pipe to show the street that it's on) I tried performing a spatial join based on 'closest' but I encountered the following problem: many pipes never intersect the center of the streets they're on (they are usually parallel), and, at the spatial join, those respective pipes don't get the needed data from the street they go along but from the ones that are perpendicular (cause they intersect the pipes, so they have one point that is closest).


I've face a similar problem and created a programmatic tool that would:

  1. Shorten my street centerline. Here I would take it from .4 to .6 for example (in this case I would consider only the dashes)



    After shortening


  2. I would buffer it for a small ammout, let's say 10% of the original street lenght. Imagine that you are buffering only the dashes in the schematic "drawing above".

  3. Try to intersect it with pipes.

You can repeat 2 and three until you've found a certain number of pipes. The idea for shortening the center line is to eliminate the cases where you other perpendicular lines that you do not want.

Check a less ugly scheme:

enter image description here

Another approach is to just buffer, intersect and compare the angles. You can safely set a threshold of what "parallel" is. You will never have straight and parallel lines in this cases (some will be parallel, but that depends on digitizing). You take only the pipes that have similar angles to your centerline.

  • Thanks for the answer, I hoped for a different answer, I will try to do something alike. – tudorbarascu Jul 25 '11 at 4:14
  • I'll see if I can find some code to help you. This method improves confidence of the results, it's not the most pratical, but it works great on regular grids. The more irregular the street network the less confidence you can have with it. – George Silva Jul 25 '11 at 14:29

I wrote a tool that does exactly this. It's called Spatial Angle Join.

Joining line features based on their polar angle

Polar angle: The angle the line would form with the equator if it was extended to intersect it.

  1. Calculate the polar angle of the pipes.
  2. Calculate the polar angle of the roads.
  3. Spatially join the road lines to the pipe lines within a radius (one to many).
  4. Find the difference between the pipe angles and the joined road angles.
  5. Keep the road that had the smallest difference in polar angle.

An example

Joining road features with sanitary mains. A road pointing north will have an angle of 90 degrees with respect to the equator and a road pointing east will have an angle of 0 degrees because it is parallel to the equator. The sewers mostly run parallel to the road so if there is a sewer with an angle of 85 degrees it will be matched with the road going north because 85 degrees is closer to 90 degrees than 0 degrees.

Joining the color of the roads to the sanitary mains.

Before Join enter image description here


enter image description here


You could try using the Near geoprocessing tool:

Determines the distance from each feature in the input features to the nearest feature in the near features, within the search radius.

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.