# Point to Polygon with Fixed Spatial Attributes [closed]

I have a point dataset with 3 useful columns. Those are width, height and direction (degrees from 1 to 360). I would like to create rectangles using the width and height, and with the specific direction (orientation), either using ArcGIS or R code. Any ideas?

• Please pick one software stack, as per the One question per Question policy. Note that 365 is 5 degrees too many for a proper degree range. Mar 26, 2020 at 21:22
• Yes it's 1 to 360! (I believe I was thinking on days) Mar 26, 2020 at 23:58
• What are the units of width? Are the rectangles large? Because a rectangle on a sphere is going to be very different to a rectangle in an X-Y coordinate system. Mar 27, 2020 at 8:01
• Units are meters (the result would change but the process is the same). Mar 27, 2020 at 15:05

import arcpy

def rotateXY(x,y,xc=0,yc=0,angle=0,units = "DEGREES"):
import math
x = x - xc
y = y - yc
if units=="DEGREES":
xr = (x*math.cos(angle))-(y*math.sin(angle)) + xc
yr = (y*math.sin(angle))+(y*math.cos(angle)) + yc
return xr,yr

def createIndexPoly(X,Y,h=5,w=5,sr=None):
angle = 20
if not h is None and not w is None:
### set up editor

arrPnts = arcpy.Array()
# point 1
pnt = arcpy.Point(X-w/2,Y-h/2)
pnt = arcpy.Point(rotateXY(pnt.X,pnt.Y,X,Y,angle)[0],rotateXY(pnt.X,pnt.Y,X,Y,angle)[1])
# point 2
pnt = arcpy.Point(X-w/2,Y+h/2)
pnt = arcpy.Point(rotateXY(pnt.X,pnt.Y,X,Y,angle)[0],rotateXY(pnt.X,pnt.Y,X,Y,angle)[1])
# point 3
pnt = arcpy.Point(X+w/2,Y+h/2)
pnt = arcpy.Point(rotateXY(pnt.X,pnt.Y,X,Y,angle)[0],rotateXY(pnt.X,pnt.Y,X,Y,angle)[1])
# point 4
pnt = arcpy.Point(X+w/2,Y-h/2)
pnt = arcpy.Point(rotateXY(pnt.X,pnt.Y,X,Y,angle)[0],rotateXY(pnt.X,pnt.Y,X,Y,angle)[1])
# point 5 (close diamond)
pnt = arcpy.Point(X-w/2,Y-h/2)
pnt = arcpy.Point(rotateXY(pnt.X,pnt.Y,X,Y,angle)[0],rotateXY(pnt.X,pnt.Y,X,Y,angle)[1])