This content has been marked as final. Show 5 replies
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/file/geoprocessing/details?entryID=3D230972-1422-2418-34A5-2F3FFF97C238 is for ArcGis 10.
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,
RotateExample2.jpg 9.7 K
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.
Here is some sample code if interested:
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)
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,