+ Reply to Thread
Results 1 to 6 of 6

Thread: Rotate Feature or Find Rotating Envelope Polygon

  1. #1
    Dwight Lanier
    Join Date
    Feb 2011
    Posts
    14
    Points
    6
    Answers Provided
    2


    0

    Default Rotate Feature or Find Rotating Envelope Polygon

    Couldn't find anything posted on this, if I overlooked, please redirect, otherwise:

    Ultimate Goal: Create a series of polygons (each polygon in it's own separate shapefile) whose width is the same as the width of an input feature, but at different angles from 0 - 360 degrees. See attached image where the red lines would represent the extent of the feature at different angles of rotation.

    Method: I'm looking to find the min and max x value of a single polygon feature, which can easily be done when the feature is sitting in it's normal angle of 0 degrees rotation by using the properties or the create envelope polygon tool. To build the other polygons that show the width of the feature at different angles, I would think that it's easier to rotate the input feature one degree, recalculate the extent rectangle as if it's sitting at zero degrees rotation, and then rotate the extent rectangle back the same degree of rotation that the input feature was rotated.

    Question: How can I use Python to rotate a feature in ArcGIS 9.3?

    Thanks!

    Dwight
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	RotateExample.JPG‎
Views:	172
Size:	18.7 KB
ID:	6371  

  2. #2
    Dan Patterson

    Join Date
    Apr 2010
    Posts
    1,755
    Points
    442
    Answers Provided
    41


    0

    Default Re: Rotate Feature or Find Rotating Envelope Polygon

    The Minimum Area Bounding Rectangle has been implemented already in the Bounding Containers toolset. It does exactly what you want and the code can be extracted from the Python scripts. This version http://resources.arcgis.com/gallery/...5-2F3FFF97C238 is for ArcGis 10.
    Geomatics, Carleton University, Ottawa, Canada
    http://obidangis.blogspot.ca/

  3. #3
    Dwight Lanier
    Join Date
    Feb 2011
    Posts
    14
    Points
    6
    Answers Provided
    2


    0

    Default Re: Rotate Feature or Find Rotating Envelope Polygon

    Dan, thanks for the reply, but I don't think that this is what I'm looking for.

    What I need is a regular bounding extend rectangle, but for different angles of rotation. See attached image 2 for a bit of clarrification. I need a regular bounding rectangle so i can extend it out and find features that cross the width of the input feature (like the green line) which I will then clip. A minimum area bounding rectangle doesn't give me these extended lateral lines for the feature at all intermidiate angles. Unless the toolset you linked to provides min max coordinates at each angle of rotation, then that could be used?

    As in the example picture, I would do this for 90, 91, 92, etc. degrees looking for features with a certain criteria that fall within that area for each angle. As you look at the input feature from different angles you will get different areas of influence before and after the feature.

    This is why I think it might be easiest to rotate the input feature and then do a standard extent rectangle and then rotate the extent rectangle back.

    Thanks again for the try,

    Dwight
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	RotateExample2.jpg‎
Views:	88
Size:	9.7 KB
ID:	6372  
    Last edited by dwightlanier; 05-06-2011 at 01:50 AM.

  4. #4
    Jake Skinner

    Join Date
    May 2010
    Posts
    1,598
    Points
    1122
    Answers Provided
    178


    0

    Default Re: Rotate Feature or Find Rotating Envelope Polygon

    There is a Rotate GP tool, but this is only for raster datasets. You could create a script to convert the features to a raster dataset (Polygon to Raster), rotate the raster datasets (Rotate), then convert the rasters back to a feature class (Raster to Polygon). You will then be able to retrieve the new extent of the rotated feature.

  5. #5
    Jake Skinner

    Join Date
    May 2010
    Posts
    1,598
    Points
    1122
    Answers Provided
    178


    1

    Default Re: Rotate Feature or Find Rotating Envelope Polygon

    Here is some sample code if interested:

    Code:
    list = []
    
    # Specify feature class whose features you want to rotate
    # Append to list to find the Max OBJECTID/FID
    lstFCs = arcpy.ListFeatureClasses("Parcels")
    for fc in lstFCs:
        rows = arcpy.SearchCursor(fc)
        for row in rows:
            list.append(row.OBJECTID)
    
    del row, rows        
    
    maxOID = list[-1]
    
    x = 1
    y = 1
    
    # Loop through each feature, convert to a feature layer, then to raster, rotate raster, convert back to polygon feature class
    while y <= maxOID:
        for fc in lstFCs:
            feat_lay = arcpy.MakeFeatureLayer_management(fc, fc + str(x), "OBJECTID = " + str(x))
            ras_lay = arcpy.PolygonToRaster_conversion(feat_lay, "OBJECTID", fc + str(x) + "_ras") # Can improve processing time by specifying a larger cell size
            feat_lay2 = arcpy.Rotate_management(ras_lay, "ras_rotate" + str(x), 45)
            arcpy.RasterToPolygon_conversion(feat_lay2, fc + "_rotate_" + str(x))
            y = y + 1
            x = x + 1
    
    # Print extent of rotated feature classes
    lstFCs2 = arcpy.ListFeatureClasses("*rotate*")
    for fc2 in lstFCs2:
        rows2 = arcpy.SearchCursor(fc2)
        for row2 in rows2:
            geom = row2.Shape
            Extent = geom.extent
            print Extent
    
    del row2, rows2
    
    # Deleted rasters
    lstRasters = arcpy.ListRasters("*ras*")
    for raster in lstRasters:
        arcpy.Delete_management(raster)

  6. #6
    Dwight Lanier
    Join Date
    Feb 2011
    Posts
    14
    Points
    6
    Answers Provided
    2


    0

    Default Re: Rotate Feature or Find Rotating Envelope Polygon

    Jake,

    Thanks for the reply; I think this will work for what I need. I'll have to look at the effects of rasterizing the boundary of the input feature, but as long as I do each angle of rotation from the original input feature it should be controllable.

    Also this is a lot less of a headache than trying to implement some sort of rotating calipers function with a convex hull. My friend Rick suggested an ArcObjects approach, but I would really like to think that there is an accessible solution to rotating objects with python? That and I don't have the time it would take to dust off my VBA or .NET skills.

    Anyway, thanks again,

    Dwight

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts