Mexican Spotted Owl, stretching...

ArcGIS Tools
ArcView 3.x Extensions
GIS Consultation
Unit Converter
Jenness Enterprises
Search

 

Dissolve Adj. Polys

NAME:  Dissolve Adjacent Polygons, v. 1.8a    (Click Name to Download)

Aka:  diss_adjac.avx

Last modified:  March 22, 2006

TOPICS:  ArcView 3.x, polygon, dissolve, merge, union, eliminate, adjacent, combine, sliver, attribute

AUTHOR:  Jeff Jenness

Wildlife Biologist, GIS Analyst

Jenness Enterprises

3020 N. Schevene Blvd.

Flagstaff, AZ 86004
(928) 607-4638
[email protected]

DESCRIPTION:  This extension enables the user to eliminate small polygons by combining them with larger adjacent polygons.  You begin by specifying a size limit and the extension will eliminate all polygons smaller than this limit.  The extension creates a new shapefile of combined polygons so your original polygon theme is not altered.  All attributes of the larger polygon will be saved.

This function is especially useful for eliminating small sliver polygons that may be created during digitizing, and is also useful for projects that require a set of polygons that are all greater than a particular size.

All or only selected records:  You can either analyze all the polygons in the polygon theme to see if they should be dissolved or only a selected subset of polygons.

Option to use attribute values:  You can choose which adjacent polygon to dissolve in to based purely on the size of the polygon, or you can dissolve only into polygons with identical attribute values.

Combine with either largest or smallest adjacent polygon, or with polygon with longest adjacent border:  You may specify which larger polygon you want your small polygons to be combined with based on the size or border length of the adjacent polygons. If two small polygons combine, and the new polygon is larger than your specified limit, then that new polygon will not be combined into any larger adjacent polygons.

Two options for "Adjacent":  This extension allows you to define "adjacent" as meaning that the two polygons share either a common border or a common point. If you imagine a chess board, two same-colored squares that touch each other diagonally are adjacent at a single point. This extension gives you the option to decide whether that type of adjacency is good enough for your purposes, or if you need the two polygons to share a common boundary.

Report of polygon actions:  After the extension finishes, you will get a report of all the small polygons that were eliminated and which larger polygon they were combined with. This report is saved to the hard drive as a text file.

Requires:  This extension requires at least a single polygon theme present in a view. It will ask for a field with unique values for each feature, but such a field is not necessary.

This extension also requires that the file "avdlog.dll" be present in the ArcView/BIN32 directory (or $AVBIN/avdlog.dll) and that the Dialog Designer extension be located in your ArcView/ext32 directory, which they usually are if you're running AV 3.1 or better. The Dialog Designer doesn't have to be loaded; it just has to be available. If you are running AV 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

Recommended Citation Format: For those who wish to cite this extension, the author recommends something similar to:

Jenness, J. 2006. Dissolve adjacent polygons (diss_adjac.avx) extension for ArcView 3.x, v. 1.8a. Jenness Enterprises. Available at: http://www.jennessent.com/arcview/dissolve_adjacent_polys.htm.

Please let me know if you cite this extension in a publication ([email protected]). I will update the citation list to include any publications that I am told about.

Updates: Version 1.4 (Oct. 7, 2003) changes some of the algorithms to make it run faster, and changes the method of identifying adjacent polygons so that it doesn’t occasionally miss polygons that lie completely within another polygon. Also several cosmetic changes

Version 1.5 (Dec. 11, 2003) fixes a bug that caused the extension to hang if it encountered multiple null polygons. Also gives the user the option to only consider a selected subset of polygons to dissolve.

Version 1.51 (Jan. 29, 2004) corrects a bug in which it was incorrectly identifying adjacent polygons that only touched at a single vertex.

Version 1.52 (February 28, 2004) adds the option to combine small polygons with adjacent polygon having the longest common border.

Version 1.7 (February 7, 2005) adds the option to dissolve based on common attribute values, plus adds a Table menu item to add record numbers to the table.

Version 1.8 (March 10, 2006) corrects a bug that could occur if the ID field contained a long alias, as well as adds a function for searching for errors in the scripts.

Version 1.8a (March 22, 2006) corrects a bug caused by the last revision. Sorry about that!
 

General Instructions:

1)  Begin by placing the "diss_adjac.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 "Dissolve Adjacent Polygons"

3)  From a View, select the icon from the View.

4)  You will now see the "Select Polygon Theme and Dissolve Options" dialog box:

Polygon Theme and ID Field:  Begin by selecting the polygon theme and an ID Field that uniquely identifies the polygons.  This ID field is only used for generating the report, so it's not necessary for the calculations.  If you don't have an ID field and you don't feel like making one, you can select "- No ID Field -" and the extension will run just fine.

Size Limit:  Next specify the size limit for small polygons.  All polygons smaller than this limit will be dissolved into larger adjacent polygons.  If you have a polygon that is smaller than the limit, but is not touching any other polygons, then it can't be dissolved.  You will be alerted to that circumstance at the end of the script's operation, and there will also be a note in the report.

Choose All Polygons or Selected Polygons:  If you have a very large number of polygons to dissolve, you may find it helpful to pre-select different regions of the theme or perhaps different size ranges of polygon to work with.  If you choose to dissolve only selected polygons, then the tool will only consider dissolving those small polygons that are already selected. This will NOT affect which adjacent polygon a small polygon may be dissolved into. They may still be dissolved into non-selected polygons, but no non-selected polygon will be analyzed with this option.

Only dissolve polygons with same attribute value:  This option will only dissolve polygons into other polygons if they have the same attribute value. If you choose this option, you will need to select the attribute field before you can click the 'OK' button. After you select the attribute field, the field name will appear on the button to indicate that the attribute field has been chosen.

Size Option:  Next decide whether you want the small polygons to be dissolved into the smallest or largest adjacent polygons, or the polygon with the longest common border. If two small polygons are combined early in the process, and the combined polygon is larger than the specified size limit, then that new polygon will not be dissolved into any adjacent polygons.

Adjacency Option:  Finally, decide what rule of "adjacent" you want to use.  In the following illustration, Polygon 1 touches three other polygons (Polygons 2, 3 and 4).  However, it only touches Polygon 4 at a single point.  If you want to allow Polygon 1 to be combined with Polygon 4, then use the "Share common point or vertex" option.  If you want would rather that Polygon 1 be restricted such that it can only be combined with Polygons 2 or 3, then use the "Share common line or border" option.

5)  Specify hard drive location to save the new shapefile:  You will still be prompted to specify a location on the hard drive to save the new shapefile of combined polygons.  This shapefile will also appear in your view.  This is a standard ArcView Dialog Box and should be familiar to most users. This shapefile is permanent and will not be deleted when ArcView is shut down.

6)  Report:  After the extension finishes, you will get a popup window with a report detailing which polygons were combined and in what order.  This report is also saved to the hard drive at the location mentioned in the popup window:

 

Adding Record Numbers to Table:

This option provides a simple way to add a field of record numbers to your table. Many types of analysis require that you have some kind of unique ID value in your attribute table, and record numbers usually make good ID values when no other option exists. This extension also asks for a field of unique ID values, although it is not critical to the analysis and is only used to identify which specific polygons were dissolved in the report.

All you need to do is open your table, click the “Edit” menu, and then click “Create Record Number Field”. The table does NOT need to be set to Editable prior to this. The tool will add a field named [rec_num] and populate it with record number values. If a field named [rec_num] already exists in your table, the tool will append an index number to the name until it finds a name that does not exist in your table (i.e. [rec_num_1], [rec_num_2], etc.)

Calculation Methods:

  1. This extension begins by copying the polygon shapefile into a new shapefile at the specified location and adding two new fields to the new shapefile:

    1. rec_num:  The record number of that polygon in the Feature Attribute Table.  This extension requires that each polygon be uniquely identified, and the record number guarantees a unique identity.  This is different than the Unique ID field specified by the user, which is only used in providing Polygon ID values for the report.

    2. dslv_area:  The area of the polygon.  This field is used to identify those polygons that are smaller than the specified area.

  2. Using the area values from the dslv_area field, the extension identifies all those polygons that are smaller than the specified size.  It then makes a list of those small polygons and sorts the polygons by size, from the smallest to the largest.

  3. Beginning with the smallest polygon (or the first polygon in the list), the extension selects all the surrounding polygons that the small polygon touches.  This selection includes all those polygons that the small polygon touches at only a single point.

    1. If the user has selected the "Share common line or border" option, the extension then checks all the selected polygons and discards those that only touch at a single point.

    2.  This option also checks whether the smaller polygon is enclosed by the larger.
    3. If the user has specified an attribute field, then the extension checks all the selected polygons and discards those with different attribute values.

    4. The extension then checks the size of all the remaining selected polygons and identifies either the largest, smallest, or the one with the longest common border, based on the user's choice.

    5. After identifying the largest/smallest polygon, the extension then performs the UNION request to combine the two polygons.  This generates a brand new combined polygon that is completely separate from the original small and large polygons.  The extension then runs the CLEAN request to ensure that the new polygon is a valid polygon.

    6. The extension then replaces the original large polygon with the new combined polygon, such that all the attribute values of the original large polygon now are associated with the new combined polygon.  The original large polygon is now gone. 

    7. The extension then deletes the smaller polygon from the shapefile entirely.

    8. It's possible that the small polygon will be an island somehow and have no other polygons adjacent to it.  If this is the case, the extension will skip this polygon and insert a note in the report stating that this polygon had no adjacent polygons and therefore could not be combined with any.  If this happens, you will be notified of all such island polygons in an alert popup window after the extension finishes running.

  4. The extension then proceeds to the next small polygon in the list.  It's possible at this point that the current small polygon has already been combined with an even smaller polygon, and that the new size is larger than the specified size limit.  If this is the case, the extension will skip this polygon and insert a comment in the report stating that the polygon no longer needed to be combined with an adjacent large polygon.  Otherwise, the extension will repeat the process described above.

  5. The extension then repeats the entire process for all the remaining small polygons in the small polygon list.

  6. After dissolving all the small polygons in the shapefile, the extension then removes any null polygons that may be present.

Troubleshooting:

Please let the author know If the extension crashes for any reason. If it does crash, and if ArcView is still running, click the menu item “Check ‘Dissolve Adjacent’ Scripts” in the View “Help” menu to generate a report of all scripts that appear to be malfunctioning. Please copy this report into an email or text file and email it to the author. This report will help the author to identify and fix the problem.

Enjoy! Please contact the author if you have problems or find bugs.

            Jeff Jenness                                      [email protected]

            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 ArcView-based GIS consultation services to help you meet your specific data analysis and application development needs.