# How to create perpendicular line from point on one line to an intersection with the nearest polygon layer?

I am trying to create laterals from a layer of sewer mainlines and have yet to Google a thoroughly helpful answer. Hoping to find some help here.

I have a layer of mainlines that have a direction associated with them pointing from upstream to downstream. I have tabular data that represents the intersection of a lateral line with the mainline. It has the ID of the mainline, the distance from the upstream manhole where it intersects and the side of the mainline that it is on (numbers 0-12, directly downstream being 0/12 or directly upstream being 6, 7-11 being to the left of the downstream direction of the line). I need to create perpendicular lines from these intersection points to the nearest polygon in my parcel layer and extend that lateral line 2 feet into the parcel. I also need to add that parcel number to the lateral in my attribute table and label the laterals ID_1, ID_2, ID_3, etc. on each mainline.

So far in ArcMap 10.0 sp4 ArcInfo license, I have created a set of points representing those intersections on the mainline. With Linear Referencing, I created routes out of the mainlines and then made an event layer of lateral lines using the distance from the "zero" measure of the mainline. Now I'm stuck. How do I make perpendicular lines on the correct side of the mainline for these 45k laterals to cross 2 feet into the nearest parcel polygon?

-
Is there a threshold for the maximum distance to look for the parcel polygon nearest to the mainline ? Maximum lateral length, in other words. – Kirk Kuykendall Mar 19 '13 at 1:50
No. Essentially the lateral line will just go perpendicular from the main to where it crosses into a parcel. We'll have to go back and manually update some of them that go through one parcel to a back lot or something like that, but at least the first 40k will hopefully be done with Arc tools. I guess I could give a maximum of a quarter mile or something, if a maximum was necessary. – Kirsten Mar 19 '13 at 17:34
Looking at old data, auto-generated, the longest would be 107 feet. – Kirsten Mar 19 '13 at 17:58
Is a programmatic solution acceptable? – Kirk Kuykendall Mar 19 '13 at 20:57
I suppose it depends on what you mean by a programmatic solution. Python? .Net? I could probably figure out how to implement either. I started down both those paths and got lost. – Kirsten Mar 20 '13 at 22:30

Here's some pseudo code with notes for the arcobjects interfaces you could use. I've made this community wiki since I don't have time to go into details.

``````Foreach lateral
// use IFeatureClass.Search with queryfilter
mainline = findmainlinebyid(lateral.mainid)
// use IMSegmentation2.GetPointsatM
point1 = mseg.Getpoint(lateral.measure)
// use ICurve.QueryNormal
polyline1 = constructperpendicular(point1,mainline,length)
// use IFeatureclass.Search with spatialfilter
listofparcels = getintersectedparcels(polyline1)
// loop through each parcel calling IProximityOperator.ReturnDistance
closestparcel = getclosestparcel(point1,listofparcels)
// use ITopologicalOperator.Intersect
multipoint = getcrossingpoint(closestparcel,polyline1)
// use IproximityOperator.Return distance to get closest point
point2 = getclosestpoint(multipoint,point1)
// use ipointcollection to create a polyline
polyline2 = makepolyline(point1,point2)
// use ICurve.QueryPoint with distance of 2
polyline3 = ExtendPolyline(polyline2, 2)
// use IFeatureClass.CreateFeature(), store
WriteFeature(polyline3,lateral.mainid)
next lateral
``````
-
Thank you, I'll try this. – Kirsten Mar 25 '13 at 14:34