Select to view content in your preferred language

Clip out polygon areas parallel to other polygons?

567
3
01-20-2026 01:08 PM
MaryDuBose1
New Contributor

I have a geospatial problem that I can't seem to figure out, and I'm wondering what combination of geoprocessing tools, if any, could get me the result I need. Also open to any suggestions outside of the box for how to solve this.

I have roadway segments (lines), road intersections (points), and "adjacent block areas" (polygons). For all parts of the roadway segment that are touching an adjacent block area, I want to use that adjacent block polygon for my calculation. But where there is no adjacent block, I want to use a 2000' buffer. Either way, I need to calculate the number of intersection points inside my selected polygons. 

In the image below, the green areas are the adjacent polygons and the blue area is just a 2000' buffer. The areas outlined in the orange dashed line are what I'm trying to remove from the analysis. I need to calculate the number of points that touch the green polygons PLUS the number of points that touch the 2000' buffer but only where there is no green polygon for that part of the roadway, looking at the left and right sides of the road separately.

 

Screenshot 2026-01-20 125630.png

0 Kudos
3 Replies
DavidSolari
MVP Regular Contributor

I was staring at this for minutes trying to figure out where the polygons were until I broke out the eyedropper tool. For anyone else with some red-green color blindness, here's a version of the OP's image with the polygons' contrast blown out:

DavidSolari_0-1769013701377.png

 

I don't have a solution right now, but to confirm some things: is the attached data and image consistent with how your data is laid out? Have I classified my demo points correctly based on the results you're looking for?

DavidSolari_1-1769013818041.png

 

0 Kudos
DavidSolari
MVP Regular Contributor

Alright, given the limited test data I've made, I think I have a working concept. This requires that the roadway segments don't have any gaps in each working area, and the block areas touch the roadway segments in at least two places.

  1. Run Feature Vertices to Points on the block areas, then Delete Identical on the Shape field to remove the double origin vertices.
  2. Spatial Join the vertices to the roadway, unchecking the keep all option. You now have just the block vertices that touch the roadway, with the roadway segment attributes as well.
  3. Make a polyline feature class and add two fields: a field to hold a related Object ID, and a field to track left vs. right side. We'll call this "Traces".
  4. It's Python time! Use a Search Cursor to make a dictionary of roadway keys to "SHAPE@" geometry data.
  5. Create an Insert Cursor for Traces (related OID, "SHAPE@" geometry and side fields) and a Search Cursor for the spatially joined points ("OID@" object ID field, "SHAPE@" geometry field). For every point:
    1. Get the line geometry from the dictionary.
    2. Use the line's measureOnLine method to get the measure of the point along the line.
    3. Get a  "p1" point from the line with the positionAlongLine method and subtracting a very small distance from the measure.
    4. Do it again to get a "p2" point but add a very small distance to the measure.
    5. Use the angleAndDistanceTo method of p1 to p2 to get the rough heading angle of the line at that point.
    6. Use the pointFromAngleAndDistance method of the original point with the buffer distance and the heading minus 90, this creates an endpoint from the original point out to the left.
    7. Use the Polyline constructor to turn these two points into a line. You can get the spatial reference from the original point.
    8. Insert the polyline, the point's Object ID and a "left side" side value into Traces using the Insert Cursor.
    9. Repeat steps 6-8 but add 90 to the heading instead, and use a "right side" value.
  6. You now have a bunch of perpendicular lines shooting out from the roadway. We need to turn these into polygons, so start by Dissolving the roadway segments into one single line feature.
  7. Get a sorted list of those spatial join points with their Object IDs, sorting on their measure along the dissolved roadway line. I'll toss in the code for this one as sorting with a key is a bit more advanced than your usual Python:
line = next(arcpy.da.SearchCursor("Dissolved Roadway Segments", "SHAPE@"))[0]
def _sort_by_length(row):    
    return line.measureOnLine(row[1])
sorted_points = sorted(arcpy.da.SearchCursor("Spatial Join Points", ("OID@", "SHAPE@")), key=_sort_by_length)​
  • Search Cursor through the Traces and build a dictionary of related Object ID to "SHAPE@" geometry twice over. The first time filter to just the left side lines and the second to the right side lines.
  • Create a Polygon feature class to hold the data from the next steps and create an Insert Cursor for it, no extra fields required.
  • Get the first point from the sorted points as the "last_point".
  • For all the remaining sorted points:
    1. Use the OID of the last_point on the left side trace dictionary to get the first line geometry.
    2. Use the OID of the current sorted point on the left side trace dictionary to get the second line geometry.
    3. Build a Polygon using these points: firstPoint of first line, lastPoint of first line, lastPoint of second line, firstPoint of second line, and firstPoint of first line again to close it.
    4. Insert that polygon using the Insert Cursor.
    5. Repeat steps 1-4 but use the right side traces dictionary to get the two lines.
    6. Set last_point to the current point so it's ready for the next loop iteration.
  • Erase the block areas from these new polygons.
  • Select all erased polygons that "Share a line segment with" the block areas.
  • Remove from selection any erased polygons that "Share a line segment with" the roadway segments.

Phew, that was a lot! But from my limited testing this gives you a bunch of polygons that indicate points to exclude from further processing. Hope this gets you started on something. I also welcome anyone reading this to reply with better ways to do all the geometry nonsense I laid out.

0 Kudos
DavidSolari
MVP Regular Contributor

Just thought of one last thing to try: if you have a 3D Analyst license you can extrude your block areas into extremely tall buildings and poke around the Visibility tools. This might be the most accurate way to figure out which areas are "in shadow" and can be culled.

0 Kudos