I have a line shapefile with speed restriction attribute on each edge. I like to verify differences between two consecutive edges for all shapefile edges.

Example: One line has speed restriction set to 120 and the next consecutive edge has speed restriction set to 50.

I want these differences selected, or highlighted.

My problem is that I have major differences between edges that isn't according to reality, and I need to verify each one of those.

My shapefile is dissolved using speed restriction attribute, I'm using ArcMAP 10.1.

Anyone has a clue on that?

  • There is no out-of-the-box tool for that available. Are you able to work with or write Python code? – Alex Tereshenkov Jun 22 '15 at 13:23
  • Yes, I'm able to do so. I don't have much knowledge on these codes, but if you give me some information I can work on it. thx. – Ycavazin Jun 22 '15 at 13:28
  • What kind of comparison are you looking to make, programmatic or visual inspection? Is there a minimum or maximum value difference you want to compare? A quick visual method would be to symbolize the lines on that field using a progressive color ramp (think rainbow). Any severe differences between one section and another should show up as very contrasted colors rather than smooth transitions (ie red next to green means a significant difference in speed). – Chris W Jun 28 '15 at 5:53
  • Thanks for your support, but I want to flag discrepances by comparing it attribute table. I'm trying @fatih_dur solution. But your solution is also good, unfortunatelly I have more than 700k lines and it will take so long time. – Ycavazin Jun 29 '15 at 13:35

Assuming you will follow a manual verification process, I can suggest you somewhat quick and dirty solution:

  • First by using Feature Vertices To Points tool (Data Management Tools\Features\Feature Vertices To Points) with BOTH_ENDS option, generate start and end points of each line segment (be aware that each segment will be your unit of analysis);
  • Second, apply Spatial Join tool by picking previously generated point feature class as Target and Join Features. This should report attributes (in your case this will be speed) of all intersecting start and end points by creating unique fields (say SPEED is the field in your line feature class, you will have SPEED and SPEED_1 fields);
  • Lastly, by using Select by Attribute tool, you can query the desired differences (say road segments of 100 km/h or higher and speed difference is 30 km/h can be queried as (SPEED>=100 OR SPEED_1>=100) AND (ABS(SPEED-SPEED_1)>=30) )

Please be aware that this method is for consecutive segments and you may be required to follow a different approach if you have overlapping lines or intersections.


What you will need to do is outlined as below. Make sure your lines are connected at end vertices only (if they are not, use the Split Line At Vertices (Data Management) tool).

  1. Iterate your line features and create a list of pairs of lines which share end/start vertex. Use ObjectID as an unique line feature ID. You should have [(45,50),(50,52),(52,67)] by now.

  2. Iterate every pair of lines and find out the difference between the speed values. You could construct a dict or use tuples, shouldn't matter much unless you are processing millions of features. If a business rule is violated (e.g., the diff > 30), then append this pair line IDs to a list along with the difference value. You should have [(45,50,4),(50,52,5),(52,67,6)] by now where the last item in every tuple is the difference in speed values.

  3. Construct an SQL query such as ObjectID in (your line IDs comma separated where the diff was violated) in the Select By Attributes. ObjectID in (34,45,56)

For steps 1 and 2 you would need to use arcpy.da.SearchCursor and Geometry (arcpy) (get start and end points of each line); for step 3 to get rid of duplicates, use the Python set. More about arcpy and constructing SQL queries.

If lazy, but brave - look into networkx Python library (for working with graphs) which will let you get hands at connectivity matrix of your polyline feature class very easily.

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.