Thursday, 7 January 2016

How do I rotate the polygon about an anchor point using python script?


I know there would be no tool in arcpy module as such but mignt have in third party modules. I however tried taking the vertices of the polygon and moving using the below formula. but did not get the correct output coordinate values and polygon thus generated is wierd.


I have tried this function


def RotateAxis(AnchorX,AnchorY,inputx,inputy, WindDirection):
x = inputx - AnchorX
y = inputy - AnchorY

resultx = (x * math.cos(WindDirection)) - (y * math.sin(WindDirection)) + AnchorX
resulty = (x * math.sin(WindDirection)) + (y * math.cos(WindDirection)) + AnchorY
return (resultx,resulty)

where Anchor is the origin and WindDirection is the angle which I tried taking in radians as well as degrees but could ot get correct results.


I tried with projected coordinates that didn't work either. Is there any suggestion?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...