I need to figure out how to create "x"-lines inside buildings polygon. There is a lot of polygons so I need to make this automatic.
How do I do this using ArcGIS Desktop?
Example:
I need to figure out how to create "x"-lines inside buildings polygon. There is a lot of polygons so I need to make this automatic.
How do I do this using ArcGIS Desktop?
Example:
My suggested process is to run a Minimum Bounding Geometry, rectangle by width across the buildings to get a polygon with four corners. Connect the four corners in a cross (using a script). Finally clip the cross with the building footprint to ensure the crossed lines are only within the building footprint.
The script should look something like this:
import os
import arcpy
"""Draw diagonal lines across rectangle."""
in_features = 'PathToYourPolygons'
out_feature_class = 'PathToCrossPolylines'
desc = arcpy.Describe(in_features)
path, name = os.path.split(out_feature_class)
# Create output feature class
arcpy.management.CreateFeatureclass(
path, name, geometry_type="POLYLINE",
spatial_reference=desc.spatialReference)
# Add a field to transfer FID from input
arcpy.management.AddField(out_feature_class, "ORIG_FID", "LONG")
search_fields = ["SHAPE@", "OID@"]
insert_fields = ["SHAPE@", "ORIG_FID"]
with arcpy.da.SearchCursor(in_features, search_fields) as search_cur:
with arcpy.da.InsertCursor(out_feature_class, insert_fields) as insert_cur:
for row in search_cur:
geometry = row[0].getPart(0)
for i in range(2):
point1 = geometry[i]
point2 = geometry[i+2]
polyline = arcpy.Polyline(arcpy.Array([point1, point2]))
insert_cur.insertRow([polyline, row[1]])
Variation of Mark answer, but without scripting. So, convert minimum bounding rectangles to vertices and select them by attribute:
mod( "OBJECTID",5)=1 OR mod( "OBJECTID",5)=3
It will select 2 opposite corners of individual rectangles, because each is made of 5 points. Use points to line tool with ORIG_FID being line identifier, to create first diagonal. You'll need few more steps, because original polygons can have irregular shape:
Proceed with second diagonal and merge results if necessary.