Longest Line in Polygon (Fetch)

Geometric Tools · geoprocessing tool · by Jeff Jenness
Works at every ArcGIS Pro license level

Summary

Finds the longest straight line that fits entirely inside each polygon — the fetch when the polygon is a body of water: the longest open-water path over which wind can raise waves. Interior holes (islands) block the line; every feature reports its line with endpoints, geodesic length, and azimuth. A second mode casts directional fetch rays from station points at a fixed bearing increment, each ending at the first shoreline or an optional maximum fetch distance, with a per-station summary — plus two exact lines per station that no bearing increment could be trusted to find.

This is a modernized, vectorized port of the author's classic ArcView Longest Straight Line extension — a tool whose own manual warned that it “requires a polygon theme, and lots of time.” What once ran overnight now runs in seconds, and the answer is still exact.

The longest open-water path

On a lake, a bay, or a reservoir, the single most useful length is often the fetch: the longest straight stretch of open water. Wind blowing along that line has the greatest distance to work on the surface, so fetch is the quantity behind wave-height models, shoreline-exposure indices, and many limnological habitat measures. And note what the fetch is not: it is not the distance between the two farthest points on the boundary — on any concave water body that line cuts across land. The fetch is the longest line that never leaves the water, and an island in the way blocks it just as surely as a headland does.

Water started this tool, but any polygon asks the same question: the longest unbroken sight line through a habitat patch, the longest straight run inside a burn perimeter or a management unit. Every polygon in the input is processed, and a layer's selection is honored.

Lake Roosevelt on a topographic map with two lines: a red line connecting the lake's farthest-separated boundary points, cutting across land for most of its length, and a blue dashed fetch line staying entirely on the water along the lake's lower arm
The distinction in one map: on Lake Roosevelt, the line between the two farthest-separated boundary points spends most of its length over dry land — a meaningless number for wind or waves. The fetch line is the longest line that stays on the water, and it lives in a different part of the lake entirely.

Two corners hold the longest line

The insight that made the original ArcView extension work still drives this one: the longest interior line must pass through two of the polygon's vertices — though it may extend past them until it meets the boundary. Picture carrying a long ladder through a doorway: as you rotate it to fit, it settles against two corners. Any line that touches no corner has room to grow; a line pinned at only one corner can still pivot longer. Only when two corners hold it is there nowhere left to go.

That theorem turns an infinite search into a finite one — check the line through every pair of vertices — but a finite search can still be a long one: a boundary with 3,000 vertices offers about 4.5 million pairs, which is why the original tool wanted a full night. This version keeps the theorem and replaces the patience with a two-phase strategy. First it finds the longest vertex-to-vertex chord that stays inside the polygon, using fast vectorized geometry — that is a strong answer already, and a high bar for anything else to clear. Then, for every remaining pair, it computes a quick upper bound on how long that pair's line could possibly be, visits the candidates in descending order of that bound, and stops the moment the best line found exceeds every bound left in the queue. Nothing is approximated — the search is exact; it simply declines to examine candidates that provably cannot win.

Mode one: the longest line in each polygon

Each polygon yields one line carrying Length_m (geodesic meters), Azimuth (degrees clockwise from north), the endpoint coordinates X1/Y1/X2/Y2, Src_FID, and Part (which part of a multipart feature holds the winner) — plus any attribute fields you choose to transfer, with reserved names arriving under a Src_ prefix exactly as in the Centerline and Width tool.

Lake Roosevelt with its computed fetch line threading the open water of the lower lake between islands, beside the geoprocessing pane filled for longest-line mode with the GNIS_ID and GNIS_NAME fields transferring and the output named Lake_Roosevelt_Fetch
The mode in action on Lake Roosevelt: the polygons, two GNIS fields chosen to ride along, an output name — and the fetch line threading the lake's longest open reach, past Rabbit and Haystack Islands.

Mode two: directional fetch from stations

Wave and exposure models rarely want just the single longest line — they want to know how open the water is in every direction from a site. The directional mode casts rays from each station point every N degrees (10° casts 36 rays), each ray ending at the first shoreline it meets or at an optional maximum fetch distance — the cap matters because beyond some distance the sea is fully developed and more open water no longer raises the waves, and because an open-ocean station would otherwise cast effectively infinite rays. Stations that fall on land are nudged to the nearest point inside the water, with the move recorded in Shift_Dist and Shift_Brg.

Alongside the sampled rays, every station receives two exact answers that the bearing increment would only find by luck: MaxRay, the longest single ray from the station, and MaxChord, the longest straight line through the station. These are exact for a satisfying reason: the longest line through a fixed point must touch a polygon vertex. As a ray from the station sweeps between two boundary contacts, its reach changes smoothly in a way that always bulges downward (each wall's reach is a convex function of the angle), so the reach is never at its maximum in mid-sweep — only where the contact jumps from one boundary edge to the next, which is at a vertex. So the tool needs to test only the directions toward each vertex, and the answer is exact rather than sampled. The Kind field tells the three apart (Ray / MaxRay / MaxChord), and the rays generally do not fall on one of the sampled increments.

The optional station summary collapses each station to one point at its used (possibly nudged) location: FetchMean / FetchMin / FetchMax / FetchSD over the sampled rays, the bearing of the longest sampled ray, and the exact MaxRay and MaxChord lengths and bearings — the table wave-energy work joins on. This mode descends from the author's UOGML Wave Energy extension (Jenness 2014, University of Guam Marine Laboratory), which implemented the wave-height and wave-energy formulas of Ekebom, Laihonen and Suominen (2003) on exactly these fetch rays.

Two practical notes for this mode. First, the simplify tolerance matters far less here than in longest-line mode: the rays are cast against the boundary's edges directly, so the cost grows with the number of rays times the boundary detail — not with the square of the vertex count that makes the all-pairs longest-line search expensive. Second, stations need not sit perfectly on the water: the tool moves any on-land station to the nearest appropriate point inside the water before casting its rays, and records exactly how far and in what direction it moved (Shift_Dist, Shift_Brg), so nothing happens silently.

Lake Roosevelt with ray fans radiating from four stations, beside the directional-mode geoprocessing pane (mode and stations highlighted, 5-degree bearing increment, Station_ID transferring, ray and summary outputs named) and a pop-up window listing one station's full summary record: mean, minimum and maximum ray fetch, standard deviation, bearing of the longest ray, the exact longest ray and longest line through the station with their azimuths, and the distance and bearing the station was moved to reach water
Directional mode on Lake Roosevelt: four stations casting rays every 5 degrees, and the pop-up showing everything one summary point carries — the ray statistics, the exact longest ray (11,751.76 m at azimuth 322.9°) and longest line through the station, and the record that this station was moved 66.6 m at bearing 353.5° to reach the water.
A close-up of a shoreline: the original station point sits on land in blue, the shifted station point sits at the water's edge in yellow with the full ray fan radiating from it, and the longest ray is highlighted in dashed red and labeled Max Ray
The nudge up close: the original station fell on land (blue); the tool moved it to the nearest point on the water (yellow) and cast the rays from there, with the exact Max Ray highlighted. The move — here about 67 m — is recorded on the station's summary record.

Geographic data, honestly measured

Polygons in latitude–longitude are solved in a feature-centered azimuthal-equidistant working projection, and the final line's length is reported geodesically. In directional mode every station gets its own azimuthal-equidistant projection, so radial distances from the station are true geodesic distances and bearings are true azimuths. Very large polygons — spanning more than about 1,000 km — draw a warning: at that scale any planar solve can err by a fraction of a percent, and a true spherical great-circle mode is a planned addition.

Why the simplify tolerance matters

The candidate search grows with the square of the vertex count, so boundary detail is the entire cost of this tool — and much of that detail is often meaningless. A polygon traced from a raster carries a stair-step boundary with a vertex at every cell corner: tens of thousands of vertices that describe the cell size, not the shape. The Advanced simplify tolerance generalizes each boundary before the search (both modes); a tolerance near the raster's cell size collapses the stair-steps, typically cutting vertex counts — and run times — by an order of magnitude or more, while moving the boundary, and therefore the answer, by no more than about the tolerance. What a value means, concretely: entering 20 meters says the simplified boundary may stray up to about 20 m from the digitized one — every cove, notch, or stair-step shallower than ~20 m is flattened away and its vertices dropped, every feature larger than that survives, and the computed lines can shift by up to roughly 20 m where the shoreline moved. So set the tolerance to the size of the smallest shoreline feature that should still matter to the analysis. In testing, a raster-traced corridor that took 22 minutes exactly finished in about a minute at a cell-size tolerance, with the answer shifted by only a few meters. Leave the tolerance blank to honor the exact boundary as digitized — the right choice for hand-digitized shorelines whose vertices are all real.

Lake Roosevelt makes the case in numbers. Its shoreline, as digitized, is detailed enough that the unsimplified search faces 64,792,036 candidate vertex pairs — prohibitively long to wait through, as the left panel below shows (we canceled the run). Setting the simplify tolerance to 20 m trims the field to a little over 400,000 candidates, and the whole analysis finished in a little over three minutes — with the answer moved by no more than about those 20 m. Be prepared for long runs on detailed boundaries, and watch the progress bar: it names the polygon being worked, the stage the search is in (“screening vertex pair…” then “verifying candidate line…”), and the count completed of the total — so you always know what the tool is doing and roughly how far along it is, and can decide early whether to cancel and set a tolerance instead.

The geoprocessing pane mid-run with no simplify tolerance: the progress bar reads Polygon OID 2, screening vertex pair 30,129 of 64,792,036, at 13 percent
No tolerance: 64.8 million candidate pairs to screen — the progress label says so plainly, and we canceled.
The same run with the Advanced simplify tolerance set to 20 meters: the progress bar reads verifying candidate line 102,784 of 453,905
A 20 m tolerance: about 454,000 candidates, finished in a little over three minutes.

Relation to Esri's tools

ArcGIS Pro has no tool for the longest interior line. Minimum Bounding Geometry fits shapes around a polygon and ignores containment entirely; Polygon Main Angle reports only an orientation. This tool fills the gap at every license level, in both modes — and for the inside-fitting question generalized to shapes, see Maximum Inscribed Geometry, the deliberate dual of Minimum Bounding Geometry.

A tour of the dialog

The Geometric Tools gallery open on the ribbon, with the Longest Line in Polygon (Fetch) button, in the Geometry on Geometry row, outlined in blue
Where to find it: Longest Line in Polygon (Fetch) is in the Geometry on Geometry row of the Geometric Tools gallery, in the Geometric Tools group of the Wildlife and Forestry tab.

The mode dropdown reshapes the dialog: longest-line mode needs only the polygons and an output (as in the Lake Roosevelt figure above); directional mode opens the stations, bearing increment, maximum fetch, and the ray and summary outputs (as in the four-station figure). Attribute transfer follows the mode — from the polygons in the first, from the stations in the second — and the simplify tolerance waits under Advanced for the day a shoreline brings the search to its knees.

ModelBuilder

The tool offers a model its line outputs (the longest lines, or the rays and station summary), each carrying Src_FID for joins back to the source polygons or stations.

The Longest Line in Polygon (Fetch) tool in ModelBuilder with Lake Roosevelt as input and three outputs: the fetch line feature class, the fetch-ray feature class, and the station summary points
The tool in a model: the lake in, and all three potential outputs offered — the fetch lines, the directional rays, and the station summaries.

Parameters

LabelExplanationData type
What to computeRequired · mode Longest line in each polygon (the fetch), or directional fetch rays from station points (which also includes the exact MaxRay and MaxChord lines). String
PolygonsRequired · in_features The water bodies or analysis boundaries. Interior holes (islands) block the lines. Feature Layer
Station pointsOptional · stations Directional mode: the points to cast rays from. On-land stations are nudged to the nearest point inside the water (Shift_Dist / Shift_Brg record the move). Feature Layer
Attribute fields to transferOptional · transfer_fields From the polygons (longest-line mode) or the stations (directional mode); reserved names arrive under a Src_ prefix. Field (multiple)
Bearing incrementOptional · bearing_increment Degrees between successive rays — 10 casts 36 rays per station, 5 casts 72. Double
Maximum fetch distanceOptional · max_fetch Rays stop here even over open water (Capped = 1); keeps open-ocean stations finite and matches the fully-developed-sea idea in wave models. Double
UnitsOptional · linear_units Meters, Kilometers, Feet or Miles for the maximum fetch and the simplify tolerance. Output length fields are always meters. String
Output longest-line feature classOptional · out_lines Longest-line mode: Src_FID, Part, Length_m, Azimuth, X1/Y1/X2/Y2, plus transferred fields. Feature Class
Output fetch-ray feature classOptional · out_radials Directional mode: every ray plus the exact lines — Kind (Ray / MaxRay / MaxChord), Src_FID, Bearing, Fetch_m, Capped, plus transferred fields. Feature Class
Output station summary pointsOptional · out_stations One point per station: FetchMean / FetchMin / FetchMax / FetchSD, MaxF_Brg, the exact MaxRay_m / MaxRay_Brg and MaxChrd_m / MaxChrdBrg, and Shift_Dist / Shift_Brg. Feature Class
Simplify toleranceOptional · simplify_tolerance Advanced: generalize each boundary by this distance before the analysis (see above). Blank = the exact boundary as digitized. Double

Python

The fetch line of every lake, then directional fetch rays every 10 degrees from monitoring stations:

import arcpy
arcpy.ImportToolbox(r"C:\path\to\JennessEnterprisesTools.pyt")  # your install path
# mode options (matching is by prefix):
#   "Longest line in each polygon (the fetch)"
#   "Directional fetch rays from station points"
# linear_units: "Meters" / "Kilometers" / "Feet" / "Miles"
arcpy.jenness.LongestLineFetch(
    mode="Longest line in each polygon (the fetch)",
    in_features=r"D:\data\lakes.gdb\lakes",
    transfer_fields="Lake_Name",
    out_lines=r"D:\data\lakes.gdb\lake_fetch_lines")
arcpy.jenness.LongestLineFetch(
    mode="Directional fetch rays from station points",
    in_features=r"D:\data\lakes.gdb\lakes",
    stations=r"D:\data\lakes.gdb\wave_stations",
    bearing_increment=10.0,
    max_fetch=50.0, linear_units="Kilometers",
    out_radials=r"D:\data\lakes.gdb\station_fetch_rays",
    out_stations=r"D:\data\lakes.gdb\station_fetch_summary")

Recommended citation

Jenness, J. 2026. Longest Line in Polygon (Fetch). Wildlife and Forestry Tools add-in for ArcGIS Pro, v. 1.98 (September 2026). Jenness Enterprises. Available at: https://github.com/JeffJenness/Wildlife_Tools.

Credits and references

By Jeff Jenness, Jenness Enterprises (www.jennessent.com). A modernized port of the author's ArcView 3.x Longest Straight Line extension. The directional fetch mode descends from the author's UOGML Wave Energy extension (2014, University of Guam Marine Laboratory), which implemented the wave-exposure procedure of Ekebom, Laihonen and Suominen (2003) on fetch rays of exactly this kind.

Licensing information

Works at every ArcGIS Pro license level (Basic, Standard, Advanced). No extension licenses are required — and no Esri tool at any license level computes the longest interior line.