1

I would like to rotate point features symbols by angle of polyline that they overlap. Similar to cartographic line symbol, that can rotate to follow line angle:

enter image description here

I´m using basic license of ArcGIS 10.1. I´m not able to use Points along one or more lines at a time, with rotation solution. It was made for ArcGIS 10.3. I think that method arcpy.AddGeometryAttributes_management can be used from ArcGIS 10.2.

I followed this approach:

  • Create buffer Find upper and lower intersection (buffer x line)
  • Calculate angle
  • Update point feature attribute with calculated angle
  • Rotate point by attribute with calculated angle

Solution could by something like this:

enter image description here

2

Because I have basic licence ArcGIS 10.1. I can´t use method arcpy.AddGeometryAttributes_management.

Solution found upon comment post by @FelixIP and upon solution found for question Bearing between two points made by John Machin.

import arcpy
from math import degrees, atan2
arcpy.env.overwriteOutput = True


#input layer
fcin_points = arcpy.GetParameterAsText(0) #input point # feature layer
fcin_lines = arcpy.GetParameterAsText(1) #input lines # feature layer

#temp layer
fctemp_buffer = "in_memory/buffers"
fctemp_direction = "in_memory/directions"

#field management
arcpy.AddField_management(fcin_points,"n_IDFIELD","LONG")
arcpy.AddField_management(fcin_points,"ANGLE","DOUBLE")
arcpy.CalculateField_management(fcin_points, "n_IDFIELD", "[FID]")

#buffer and intersection
arcpy.Buffer_analysis(fcin_points, fctemp_buffer,"0.1 Meters")
arcpy.Intersect_analysis([fcin_lines,fctemp_buffer], fctemp_direction, "ALL")

#calculate angle
try:
    with arcpy.da.SearchCursor(fctemp_direction, ["SHAPE@","n_IDFIELD"]) as scur:
        for srow in scur:
            selectID = srow[1]
            PointsIDField = arcpy.AddFieldDelimiters(fcin_points, "n_IDFIELD")
            WC = PointsIDField + " = " + str(selectID)
            geom = srow[0]
            firstX = geom.firstPoint.X
            firstY = geom.firstPoint.Y
            lastX = geom.lastPoint.X
            lastY = geom.lastPoint.Y
            angle = degrees(atan2(lastY - firstY, lastX - firstX))       
            with arcpy.da.UpdateCursor(fcin_points,"ANGLE",WC) as ucur:
                for urow in ucur:
                    urow [0] = angle
                    ucur.updateRow(urow)
#Cleaning
    del scur
    del ucur

    arcpy.DeleteField_management(fcin_points, "n_IDFIELD")
    arcpy.Delete_management(fctemp_buffer)
    arcpy.Delete_management(fctemp_direction)

#how to rotate symbols
    arcpy.AddMessage("\n" + "Symbology -> Advanced -> Rotation -> ANGLE -> Arithmetric" + "\n")

except Exception:
    e = sys.exc_info()[1]
    arcpy.AddError(e.args[0] + "\n" + "Does following layer contain M coordinate?" + "\n" + fcin_lines )

Solution: Solution

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.