This question has been marked as a duplicate multiple times now. Please read the entire question before flagging it as a duplicate. The previous "duplicates" for questions about copy parallel do not produce the same result as copy parallel tool.
I am looking for an arcpy process that EXACTLY replicates the copy parallel editor tool in ArcGIS 10.3. This is not the same thing as simply offsetting lines with arcpy. That is simple, but it does not replicate the copy parallel tool.
I am using ArcMap with a STANDARD licence. Advanced licence functions won't work as a solution (buffer with flat endcaps)
As an example, I have run the script from this answer https://gis.stackexchange.com/a/181545/56638. I used an offset of x = 20 and y = -20 which produces the red lines in the image below (yellow line is original line).
Then I used the copy parallel tool and set the offset to 20. That produced the green lines in the image. These lines are exactly 20m from the original line.
The problem is that when offsetting with the arcpy solution, the angle of the line is not considered. Therefore, the red lines (produced using arcpy method) are more than 20m from the original line. If you want the offset line to be a certain distance from the original line, you would need to know the angle of the line and calculate the distances to offset x and y based on trig. I am struggling to come up with a solution for this.
Another example with the arcpy solution, with offset set to x = 20 and y = 0. This demonstrates the problems that bends cause and highlights the need to take into account the angle or bearing of the original line.
This is the code that I have tried so far:
tmpwrkspace = r'C:\Users\jasbal\Documents\ArcGIS\Default.gdb' tempFeatureClass = tmpwrkspace + "\temp_rline" tempFeatureClass2 = tmpwrkspace + "\temp_lline" fc_line = r'C:\Users\jasbal\Documents\ArcGIS\Default.gdb\RWP_Rev0_4' if arcpy.Exists(tempFeatureClass): arcpy.Delete_management(tempFeatureClass) arcpy.CopyFeatures_management(fc_line, tempFeatureClass) if arcpy.Exists(tempFeatureClass2): arcpy.Delete_management(tempFeatureClass2) arcpy.CopyFeatures_management(fc_line, tempFeatureClass2) xOffset = 20 yOffset = -20 xOffset2 = -20 yOffset2 = 20 with arcpy.da.UpdateCursor(tempFeatureClass, ["SHAPE@XY"]) as cursor: for row in cursor: cursor.updateRow([[row + xOffset, row + yOffset]]) del cursor with arcpy.da.UpdateCursor(tempFeatureClass2, ["SHAPE@XY"]) as cursor: for row in cursor: cursor.updateRow([[row + xOffset2, row + yOffset2]]) del cursor
My idea is to calculate the angle of the line and to use that in a trig function to calculate x and y offset based on the distance I want to be from the original line.
Something like this:
distance = arcpy.GetParameterAsText(0) angle = "Angle Field" obtained with search cursor xOffset = distance/cos(angle) yOffset = distance * tan(angle)
I am not sure if I have my trig correct. I need some advice on this part.
I am not looking for a complete code snippet for copy parallel. The only part I need to figure out is how to calculate the offsets correctly for a set distance from the original line based on the line angle.