5

I have a few thousand polygons (all square) that I need to rotate to various angles that are in the attribute table, and then move so that each polygon gets moved 3/4 up from the original centroid, which I have as a point shapefile. It would look like this:

enter image description here

Ideally, I would like to build a model for this process so I can repeat it in the future. I am not all that comfortable with Python, but if that is the only way to get the desired result, I will be willing to try it. I have arcGIS 10 with an ArcView license.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
katzendoodle
  • 167
  • 1
  • 2
  • 6
  • 1
    You may want to look at ETGeoWizards. There is a tool called rotate shapes. It may not do exactly what you are looking for, but there are a lot of good options. I will rotate based on a value in the polygon attribute table. You may need to do some calculations to get the exact value you need. – Ryan Garnett Jul 30 '13 at 19:56
  • 1
  • The duplicate identified by @Fezter covers off on most of this question's requirements but not the "how to work out where the rotation point should be" so I recommend that this question be edited to focus on just that part. – PolyGeo Jul 31 '13 at 02:07
  • @RyanGarnett So I tried the rotate shapes tool from ETGeoWizards, but it seems like it can only rotate all shapes to one rotation angle that must be entered as opposed to pulling rotation angles from the attribute table. Can you tell me where this option is, if it exists? Thanks! – katzendoodle Aug 02 '13 at 00:37
  • I'm sorry I dont understand your question. If you have three records in an attribute, and each of the records have different values, they will be rotated based on that value. Have you looked at the rotation options? – Ryan Garnett Aug 02 '13 at 01:07
  • @RyanGarnett this doesn't seem to be how it works. it looks like you can only rotate to one specified angle. Screenshot of ETGeoWizard I know that there is also a ETGeoWizards tool for rotating polygons, but the format is exactly the same as this. I can't find any other options! help! this is so frustrating... – katzendoodle Aug 02 '13 at 02:22
  • Have you down loaded and tried the tool yet, or just looked at it? – Ryan Garnett Aug 02 '13 at 15:25
  • Look at this post. It has a few different options. http://forums.esri.com/Thread.asp?c=93&f=987&t=210244 – Ryan Garnett Aug 02 '13 at 15:56
  • I did download and try the tool, you have to pick one specific angle to rotate all of the polygons to. As for the calc function, apparently it no longer works with GIS because the newer versions of arcmap don't read VBA anymore - I tried it yesterday and it just gave me an error. – katzendoodle Aug 02 '13 at 18:12
  • Since no one has yet attempted an Answer on this it would be an opportune time to revise your question to take account of the suggestions made. – PolyGeo Aug 12 '13 at 08:04

1 Answers1

1

I did this using a python script and numpy to help me with the matrix algebra for rotation and translation of every point.

Here is the key function. You have to unpack the vertices from the feature, transform and reassemble the feature.


import arcpy
import math
import numpy

def trans(px,py,tx,ty,angle):
    '''
    Rotate a point px,py around origin 0,0
    Sense clockwise or anticlockwise
      (default clockwise)
    Transform to plot coords tx,ty
    Does not handle z or m values
    '''
    # angle in degrees +/- 360
    th = math.radians(angle) # theta (radians)
    if sense == 'anticlock':
        matrix = [[math.cos(th),-math.sin(th),tx],
                  [ math.sin(th), math.cos(th),ty],
                  [0,0,1]]
    elif sense == 'clock':
        matrix = [[ math.cos(th),math.sin(th),tx],
                  [-math.sin(th),math.cos(th),ty],
                  [0,0,1]]
    else:
        raise Exception, "sense error in DrawPlotR"
    a = numpy.array(matrix)
    b = numpy.array([px,py,1])
    c = numpy.dot(a,b)
    return (c[0],c[1])

kimo
  • 371
  • 2
  • 7