0

I have some lines on a picture. I need a green line to be selected as a reason to having a wrong parameter which painted this line green, not red. enter image description here The yellow one seems to be almost perpendicular to red, and don't need to be selected. I tried to figure out how to make an angle list of all lines which are not red. The angle is measured in clockwise direction according to an intersection of red and other lines. Then I need to select only those lines, which angle is close to zero (or < 25 for example). How can this task be solved? Unfortunately, I don't know anything from ArcPy, use only tools from system toolboxes to make a model in modelbuilder.

  • Do this lines share end node? – FelixIP Aug 6 '16 at 2:46
  • yes, all the lines are split at their intersections and have nodes there – Pavel Pereverzev Aug 6 '16 at 7:30
  • Tricky without Python. Anyway. Derive end points for non red lines. Spatial join to red lines, closest with distance. Sort descending and delete identical by line I'd. From here it is Pythagoras, acos(distance/length) – FelixIP Aug 6 '16 at 7:49
  • @FelixIP okay, I'll try a bit later at home. Thank you for advice! – Pavel Pereverzev Aug 6 '16 at 8:12
  • @FelixIP I did almost all that you recommend but can't get about acos, it gives an error. Here are the model and results. [1]: i.stack.imgur.com/ZRaJK.png [2]: i.stack.imgur.com/AEji5.png If you could give me a tip what to do next to calculate angle between red lines and those dotes, it would be very helpful! – Pavel Pereverzev Aug 6 '16 at 17:22
2

Input:

enter image description here

Note: two highlited fields are NOT originally in the table, they will be added later.

Workflow:

arcpy.MakeFeatureLayer_management("all_lines","RED_LINES",""""COLOR" = 'RED')
arcpy.MakeFeatureLayer_management("all_lines","OTHER_LINES",""""COLOR" <> 'RED')
arcpy.FeatureVerticesToPoints_management("OTHER_LINES","C:/FELIX_DATA/SCRARCH/end_points.shp","BOTH_ENDS")
arcpy.SpatialJoin_analysis("end_points","RED_LINES","C:/FELIX_DATA/SCRARCH/sj.shp","JOIN_ONE_TO_ONE","KEEP_ALL","""ITEMID "ITEMID" true true false 20 Text 0 0 ,First,#,C:/FELIX_DATA/SCRARCH/end_points.shp,ITEMID,-1,-1""","CLOSEST","#","Distance")
arcpy.Sort_management("sj","C:/FELIX_DATA/SCRARCH/sorted.shp","Distance DESCENDING")
arcpy.DeleteIdentical_management("sorted","ITEMID","#","0")
arcpy.AddField_management("OTHER_LINES","D_2_RED","DOUBLE")
arcpy.AddJoin_management("OTHER_LINES","ITEMID","sorted","ITEMID","KEEP_ALL")
arcpy.CalculateField_management("OTHER_LINES","all_lines.D_2_RED","[sorted.Distance]","VB","#")
OTHER_LINES"
arcpy.RemoveJoin_management("OTHER_LINES","sorted")
arcpy.AddField_management("OTHER_LINES","ANGLE","DOUBLE")
arcpy.CalculateField_management("OTHER_LINES","ANGLE","math.asin( !D_2_RED!/ !LENGTH!)*180/math.pi","PYTHON_9.3","#")

Result:

enter image description here

Note that correct function (of course!) is aSin() and line directions were not taken into account

  • I'm stuck probably at the Spatial Join, also I don't get the idea about workflow you sent, it's about Python which I don't know anything about yet. I just use ModelBuilder and miss some things here i.stack.imgur.com/iE6lx.png. Field ITEM_ID was missing I add it and calculate with ObjectIDs. The parameters of Spatial join are here: i.stack.imgur.com/Renh4.png Here is how my table of spatial join looks like i.stack.imgur.com/Uo9JO.png I'm sorry about these simple things, I'm only a cartographer, not a coder. – Pavel Pereverzev Aug 7 '16 at 11:51
  • It is not a Python script each line is a tool I ised – FelixIP Aug 7 '16 at 18:32
  • I'm sorry for another comment, but I can't get an idea of setting parameters for Spatial Join tool. Unfortunately I cannot determine them in the line of workflow. Can I convert it into a model for Model Builder? And does field ITEM_ID appear while SpatialJoin is running or it have to exist from the beginning? Thank you again in adavnce! – Pavel Pereverzev Aug 8 '16 at 19:39
  • You are joining end points of non-red lines (using closest and defining field for distance) to red lines. The only 2 things that matters for you in output are: non red parent line id (called item_id in my example) and distance. I strongly suggest to read my post again, it clearly states that line unique id MUST exist, don't you see original table structure. The only thing you have to do is recreate the same table structure and follow steps one by one – FelixIP Aug 8 '16 at 20:36
  • thanks a lot, I have figured out how to assemble this model. However, I explored the Feature Vertices To Points and Spatial Join tools and found out that for calculatuing angles MID is more useful, it counts distance to lines (in my case Red ones) as if it were triangles built between point on the middle of non-red line and those which are under the investigation. Line directions in my task appeared to be an important thing and maybe the only way to perform a precise calculations was to set those points on the middle of non-red lines. – Pavel Pereverzev Aug 11 '16 at 14:45

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.