Square and finish (create features with right angles)

270
3
08-29-2024 05:48 AM
GISNewbieDev
Emerging Contributor

 

Hi,

I will have a list of points as an input. I need to create a polyline using those points, like it is happening in Square and finish tool which will close the shape and autocomplete the last two segments at right angles. Right now it is available on right click when creating features.

GISNewbieDev_0-1724935471077.png

This is the output of this operation. This operation will create 2 perpendicular lines from first and last point to close the polyline.

GISNewbieDev_1-1724935515076.png

How can I use this tool in arcpy?

@AlfredBaldenweck @HaydenWelch @BlakeTerhune @JakeSkinner @DanPatterson 

Tags (1)
0 Kudos
3 Replies
HaydenWelch
Frequent Contributor

You'll have to build it yourself using the arcpy.Geometry functions. Or use numpy like @DanPatterson to build the geometry in a more pure way then write that into the shape field of the feature.

Your general process would have to be:

  1. Skip any polyline with only 2 points (endpoint perpendiculars are parallel)
  2. Get the perpendicular lines at the endpoints of the polyline using the first and last segments
  3. Normalize those perpendicular lines to a global coordinate system (cardinal)
  4. Get the distance from the first and last points
  5. Use those angles and the hypotenuse (distance from first to last point) to find the intersection point
  6. Insert that point to the start and end of the line
0 Kudos
GISNewbieDev
Emerging Contributor

@HaydenWelch I am new to python can you guide me with some code snippets or examples or may be point me related to this around numpy?

0 Kudos
GISNewbieDev
Emerging Contributor

Can somebody guide me more on this?

@AlfredBaldenweck @HaydenWelch @BlakeTerhune @JakeSkinner @DanPatterson 

0 Kudos