I have a set of polylines (a network of streams and rivers) with information on the left and right side of the streams on riparian structure. I also have locations (points) of either side of the lines. Now I need to know on which side each point is to its nearest polyline (left or right) in order to join the data from that polyline to the point.

I have seen that there is something like iHittest which could solve my problem, but I could not figure out how this is working. Ideally, I need some "cook book recipe" what to put into the Field calculator as VB script and all its details therein. I use ArcMap 10.0.

Does anyone know how to do this?

  • Have you seen RivEX, it has a tool that will take riparian data and assign bank type. How it does it is discussed here
    – Hornbydd
    Commented Nov 19, 2014 at 18:26
  • IHitTest is an ArcObjects interface, can you do this in C# or VB.net? Commented Nov 20, 2014 at 0:41
  • Thank you Hornbydd for the interesting link. Unfortunately, the RivEX only works from 10.2.1 on and I am "still" on ArcGis 10.0.
    – Irene
    Commented Nov 20, 2014 at 12:11

3 Answers 3


After having tried some various things I came up with this:

a) I overlaid the whole study area with a polygon but made sure that the end points of the rivernetwork was just outside of the polygon. I then cut the polygon with the rivernetwork (features to polygon) and have now a new shapefile, lets call it "Area_Poly". I assigned each new polygon an ID ("Poly_ID")

b) I took the roadnetwork (that is the polylines where I want to calculate a distance to) and cut it with the "Area_Poly.shp", then I spatial join it again, so that every snip of the roadnetwork has the same Poly_ID than the polygon in which is laying.

c) Spatial join the Locations (Points) that I want to calculate the distance from, so that also those locations have the same Poly_ID than the polygon where it is inside. Add a new column called "DistRoad" as float

d) Tedious but I am sure there is some shortcut with Python (where I am not good):

  • Select attributes in the point.sph: Poly_ID
  • Select attributes in the road.shp: same Poly_ID than in points
  • Calculate NEAR
  • Use field calculator to copy the distances from NEAR_DIS to "DistRoad"
  • Delete NEAR_DIS & NEAR_FID

Repeat until all points are calculated


Alternatively, you could use the linear referencing toolbox

  1. create route feature class from you rivers using "create route" (linear referencing) and measure source = length option
  2. use locate points along routes to know where you points are. You would be interested in the offset (see option below)

NO_M_DIRECTION —The distance values in the output event table will be calculated based on the routes' digitized direction. Input features to the left of the digitized direction of the route will be assigned a negative (-), offset and features to the right of the digitized direction will be assigned a positive offset value (+).


I hope the following will contribute to a solution for you, but it isn't quite a cook-book answer. This attempt uses proximity tools and geometry comparisons to establsh the LEFT or RIGHT-side condition for the Locations Points.

My initial reaction says to create a set of Buffer polygons from your streams and rivers polygons, using the Side Type (optional) argument to produce sets of Left-of-Stream and Right-of-Stream areas respectively. A Spatial Join or Near Table operation could associate your point locations with their nearest Left-of-Stream or Right-of-Stream polygon. However, the LEFT and RIGHT buffers created off of polylines are dependent on the digitized direction of the lines; this means "LEFT" and "RIGHT" could appear arbitrary depending on the directionality of the lines.

As an alternative to this direction-dependent buffering method, maybe you could use arcpy.SearchCursor()'s to retrieve and compare Geometries between your datasets. For example:

First, you could use the Feature Vertices to Points tool to create a feature class of midpoints from your polylines (to be used in the Geometry comparison):

import arcpy    
arcpy.env.workspace = r'Path\To\Riparian\Shapefiles'
arcpy.FeatureVerticesToPoints_management(env.workspace + '\\Streams.shp',
                                        'StreamsMidpoints', "MID")

Then you could use the Near tool to establish the closest Stream Midpoint to each of your Locations Points:

arcpy.Near_analysis('Locations', 'StreamsMidpoints)

We should add an empty field to ultimately record the LEFT or RIGHT condition for the Locations points:

arcpy.AddField_management('Locations', "ON_SIDE", "TEXT")

Then, you can use the UpdateCursor to unpack and compare the geometries between a given Locations point, and its nearest Stream Midpoint. Record the result to "ON_SIDE":

cursor1 = arcpy.UpdateCursor('Locations')
for row in cursor1:
    comparisonFeatureFID = str(row.getValue("NEAR_FID"))
    locationGeometry = row.getValue("Shape") #Assuming 'Shape' is the Shape Field
    whereClause = '"FID" = ' + comparisonFeatureID
    cursor2 = arcpy.SearchCursor('StreamsMidpoints', whereClause)
    for streamRow in cursor2:
        midpointGeometry = streamRow.getValue("Shape") 
    del streamRow
    del cursor2
    if locationGeometry.firstPoint.X > midpointGeometry.firstPoint.X:
        row.setValue("ON_SIDE", "RIGHT")
    elif locationGeometry.firstPoint.X > midpointGeometry.firstPoint.X:
        row.setValue("ON_SIDE", "LEFT")
        row.setValue("ON_SIDE", "SOMEHOW THEY ARE EQUAL")
    print('Just Finished Comparing a Row')

This entire routine is predicated on the idea that X values can establish the LEFT or RIGHT condition, based on a coordinate system like the UTM, where all coordinate values are positive from an Origin Point.

  • Your assumption on the left & right condition is invalid. If a stream is headed south to north the right has a higher X value but if the stream is headed north to south the right has a lower X value. You would need to find out which segment of which path on the near feature then calculate the dot product of that segment and the nearest point in the direction of travel to find sidedness. The near tool can identify what the nearest point is enabling you to find it within the geometry to locate the segment (NEAR_X, NEAR_Y) but you will have to break the geometry down to parts/points to do this. Commented Nov 20, 2014 at 0:33
  • Here's a link to dot product in NumPy geonet.esri.com/thread/45581 for deciding which side a point is on, now you just need to work out which segment to use as the from and to. Commented Nov 20, 2014 at 0:40
  • Hey Thanks! This is a great comment and good information. This Numpy Dot Product approach is more succinct too.
    – Jim
    Commented Nov 20, 2014 at 17:22

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.