1

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:

Buildings polygon with painted "x" lines.

2
  • Are you using ArcGIS Pro or ArcMap? If you also want to ask about FME, then please do that in a separate question.
    – PolyGeo
    Oct 14, 2021 at 10:45
  • 1
    Do you want these lines to be saved in the file as polylines, or can this be done as a layer style? Oct 14, 2021 at 10:51

2 Answers 2

2

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]])
1
  • I think this question has nothing to do with the actual creation of lines as vector data. It's more a matter of configuring the style of data display. Oct 14, 2021 at 10:54
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:

  • clip diagonals
  • sort them in descending order by length
  • delete identical for ORIG_FID.

enter image description here

Proceed with second diagonal and merge results if necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.