


NAME: Longest Straight Line, v. 1.3a (Click Name to Download) AKA: longline.avx Last Modified: December 5, 2007 TITLE: Longest Straight Lines Across the Interior of Polygons, (v. 1.3a) TOPICS: ArcView 3.x, Fetch, Longest Line, Distance, Bearing, Azimuth, View, Analysis AUTHOR:
Jeff Jenness, Jenness Enterprises DESCRIPTION: This extension creates a new button on the VIEW toolbar which allows you to find the longest straightline distance across the inside of polygons. Begin by selecting an Input theme containing the polygons of interest, and this extension then calculates the longest straightline distance that is completely contained within the polygons. When the polygon represents a body of water, this longest straight line from shore to shore is called the "fetch". The extension then creates a results table (described below) containing various fields such as coordinates of the endpoints of the longest line and length of this line. CAUTION: This is not the same as simply calculating the points on the polygon that are the farthest apart from each other, or calculating the "length" or "reach" of a polygon. This extension specifically calculates the longest straight line that is completely contained within a polygon. Furthermore, if there are holes in the polygon, this extension will only consider the longest lines across the polygon that do not go through those holes. Optionally, you can request graphic lines to be drawn that illustrate this longest straightline distance. All or only selected polygons: You can either use all the polygons in the theme for the analysis or only a selected subset of polygons. If any polygons in the theme are selected, then only those selected polygons in that theme will be used in the analysis. If no polygons in that theme are selected, then all polygons in that theme will be used in the analysis. Projected vs. Unprojected Views: If your original data are in Lat/Long coordinates (the Geographic Projection) and your View has been projected, then you have the option of calculating RESULTS data based on either the Geographic Projection or your View Projection. The choice of projections can dramatically affect distances and edge points, and even which points on the polygon are considered to be farthest away from each other. Results Table and/or Polyline Shapefile: Upon completion, you will have either a polyline shapefile or a results table containing the following fields:
Optionally, you can request your Results table to be joined with your input DBF file. UPDATES: Version 1.3a (December 5, 2007) includes a minor update that allows the tool to work with PolygonM and PolygonZ shapes. REQUIRES: A polygon theme, and lots of time. This extension also requires that the Dialog Designer extension be available, which I believe restricts it’s use to ArcView versions 3.1 and above. Along with this, the file "avdlog.dll" must be in the ArcView/BIN32 directory (or $AVBIN/avdlog.dll), which it almost certainly is if you have AV 3.1 or higher. If you are running ArcView 3.0a, you can download the appropriate files for free from ESRI, at: http://support.esri.com/index.cfm?fa=downloads.patchesServicePacks.viewPatch&PID=25&MetaID=483 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ General Instructions: 1) Begin by placing the "longline.avx" file into the ArcView extensions directory (../../Av_gis30/Arcview/ext32/). 2) After starting ArcView, load the extension by clicking on File > Extensions… , scrolling down through the list of available extensions, and then clicking on the checkbox next to the extension called "Longest Straight Line, v. 1.2." 3) From a View, select the icon from the View Button bar. 4) Select Polygon Theme and ID Field: You will see the following dialog prompting them to select the Input Theme and an Input ID Field. Only Polygon themes will be listed in the list of potential Input Themes.
The INPUT theme is that polygon theme that contains the polygons of interest. If any of these polygons are selected, then this extension will only operate on those selected polygons. Otherwise this extension will work through all polygons in the theme. The Input ID Field should contain unique ID values for each polygon which will allow you to identify which polygon is being described in the RESULTS table. Optionally, you can elect to have the RESULTS table joined with the Polygon Theme Feature Attribute Table. After the extension finishes calculating the longest lines, it will create a table containing the IDs of each polygon, the X and Y coordinates of the endpoints of the longest line, and the length of this line. The fields are described in more detail near the top of this page. This dialog box also gives you the option to join the RESULTS table with the Input Theme Feature Table. If you choose this option, the RESULTS table can still always be separated by clicking on "Remove All Joins" in the table menu. Regardless of whether you join the tables or not, the table will be saved onto the hard drive. 5) Select Projection for RESULTS data: At this point, you may possibly be asked what projection should be used to calculate the RESULTS data. This option only applies if your original polygons are in Latitude/Longitude coordinates (i.e. the "Geographic" or "Unprojected" projection) and your View is set to some userspecified projection. In this case you have the option of calculating the longest lines based on either your View projection or on the original Geographic projection. This choice can have dramatic differences on distances and edge coordinates, and even on which parts of the polygons are considered farthest apart from each other. Remember that distance calculations are based on the coordinate system of the data and that therefore distances based on Latitude/Longitude coordinates will come out in units of "degrees," which are rarely useful to the user. Distances measured in "degrees" become especially problematic the farther you get from the equator, since longitudinal degrees are not the same as latitudinal degrees. The author recommends that you calculate the RESULTS data based on your View Projection rather than the Geographic projection, unless you have some specific reason to need the results to be based on latitude and longitude coordinates. 6)
Add Graphic Connection Lines:
You have the option to create a graphic line on your view that
represents the longest line across the polygon.
You can choose from a number of line colors to display this line:
7) Specify Hard Drive Location to save the RESULTS table: Regardless of whether you choose to join the RESULTS table with the Input FeatureTable, you will still be prompted to specify a location on the hard drive to save the table. This is a standard ArcView Dialog Box and should be familiar to most users. This table is a permanent table and will not be deleted when ArcView is shut down.
Calculation Methods: The strategy this extension uses is to first assume that the longest line must go through two of the vertices in the polygon. In a square, for example, the longest line will go through the corners and not the edges. However, the line may extend past the vertices and still be inside the polygon if there are inwardpointing vertices in the polygon, as illustrated below. In this example, a sample polygon has 16 vertices, labeled A through P. The longest line across this polygon (represented by the dark green line), still goes through two vertices (labeled "D" and "L"), but it extends past both vertices until it hits the edges of the polygon. Therefore, this script accomplishes it's task by making a line for every possible pair of vertices in a polygon, extending that line past the edges of the polygon, then clipping that line to the polygon borders. It then selects the longest of these lines that completely lies within the polygon boundary. CAUTION: This script can take a long time to run! In a polygon with more than a few dozen vertices, this extension calculates and clips thousands of lines looking for the longest one. In light of that, the author rigged this extension so you can either run it on all the polygons in a theme or, if you select a subset of them, then this script will only operate on the subset. Also, it'll save the result table after it finishes each polygon so if it crashes you won't have lost everything. There's a stop button that'll stop the script after it finishes whatever polygon it's currently working on and it'll save whatever results have been calculated to that point. If you have lots of polygons with lots of vertices, then this extension might be one of those you run at night or on weekends. Enjoy! Please contact the author if you have problems or find bugs. Jeff Jenness jeffj@jennessent.com
3020 N. Schevene Blvd.
Flagstaff, AZ 86004 USA Please visit Jenness Enterprises ArcView Extensions site for more ArcView Extensions and other software by the author. We also offer customized ArcViewbased GIS consultation services to help you meet your specific data analysis and application development needs.
