Is it possible to return the boundary (outside) perimeter of a polygon layer?

Let's say you have the map of the USA, for simplicity, broken down to the county level, is it possible to return the boundary map of the whole country from that map?

  • So in the example case of the US, you mean actually get the outline of the states, NOT the bounding box, right? If so, how about a dissolve of the counties layer? Commented Nov 19, 2010 at 18:47
  • @Chad Cooper - when I dissolve the layer, i still get some lines showing up for counties and states.
    – dassouki
    Commented Nov 19, 2010 at 20:18

9 Answers 9


You can just do a dissolve on the county layer (be sure to have just the counties you want to dissolve selected).

  • I'm getting some internal lines still showing up in dissolve.
    – dassouki
    Commented Nov 19, 2010 at 20:13
  • 3
    Can you buffer twice to eliminate the internal lines? Out, to "eat" the lines, then back in, to restore the original size.
    – mwalker
    Commented Nov 19, 2010 at 20:50
  • for some reason this worked. I know it's the "hackiest" of solutions, but this was the only solution that got rid of the lines
    – dassouki
    Commented Nov 22, 2010 at 14:13
  • 1
    +1 This actually is a great solution. It works by accommodating tiny slivers and overlaps in the component polygons (and also overcomes many inherent bugs in the software, too).
    – whuber
    Commented Nov 22, 2010 at 20:09
  • 1
    I used mwalker's advice to buffer out then in. I hope you can include that in your answer.
    – dassouki
    Commented Nov 22, 2010 at 20:15

You can use GRASS module: v.dissolve You only need to import your data into GRASS. Here is a screen-cast of transferring your data to Grass from inside QGis.


Allow me to plug my own project... Boundary Generator will give you both external and internal boundaries of every polygon (as line features).

Internal boundaries are attributed with the FID for each of the two polygons that share that border. External boundaries should have an FID of zero for one of those two, so they are easy to select out of the full result.

The nice thing about it vs doing dissolves is that I've added a couple of knobs over precision so it can deal with not-quite-perfect data. (How far apart should two polygon borders be to be considered a shared border? How much angle deviation is required?)

It's still in alpha and it's been a while since I've tackled an update; I'd love to hear how well it works for you!

 public static IPolygon getPolygonFromLayer(ILayer layer)
            IFeatureLayer FLayer = layer as IFeatureLayer;
            IFeatureClass FClass = FLayer.FeatureClass;
            return polygonMerge(FClass);

   private static IPolygon polygonMerge(IFeatureClass featureClass)
            if (featureClass == null) return null;
            IGeoDataset geoDataset = featureClass as IGeoDataset;

            //You can use a spatial filter to create a subset of features to union together. 
            //To do that, uncomment the next line, and set the properties of the spatial filter here.
            //Also, change the first parameter in the IFeatureCursor.Seach method.
            //ISpatialFilter queryFilter = new SpatialFilterClass();

            IGeometry geometryBag = new GeometryBagClass();

            //Define the spatial reference of the bag before adding geometries to it.
            geometryBag.SpatialReference = geoDataset.SpatialReference;

            //Use a nonrecycling cursor so each returned geometry is a separate object. 
            IFeatureCursor featureCursor = featureClass.Search(null, false);

            IGeometryCollection geometryCollection = geometryBag as IGeometryCollection;
            IFeature currentFeature = featureCursor.NextFeature();

            while (currentFeature != null)
                //Add a reference to this feature's geometry to the bag.
                //Since you don't specify the before or after geometry (missing),
                //the currentFeature.Shape IGeometry is added to the end of the geometryCollection.
                object missing = Type.Missing;
                geometryCollection.AddGeometry(currentFeature.Shape, ref missing, ref missing);
                currentFeature = featureCursor.NextFeature();

            // Create the polygon that will be the union of the features returned from the search cursor.
            // The spatial reference of this feature does not need to be set ahead of time. The 
            // ConstructUnion method defines the constructed polygon's spatial reference to be the 
            // same as the input geometry bag.
            ITopologicalOperator unionedPolygon = new PolygonClass();
            unionedPolygon.ConstructUnion(geometryBag as IEnumGeometry);

            return unionedPolygon as IPolygon;


Your getting lines when you do a dissolve because the boundaries are not seamless.

Regardless of software product, do the following:

Do an integrate. alt text

Then do a dissolve. alt text

  • I tried this several times, and it didn't work :(, I keep losing some polygons, I used a very small tolerance and a very large one as well
    – dassouki
    Commented Nov 22, 2010 at 14:12

It sounds like the Bounding Containers sample posted on arcgis.com will work for what you want.

  • This is a good thought, but that solution is unlikely to work in this fasion. It is intended to provide additional geometric information about features by finding the smallest member of a class of shapes that contains the features, such as a rectangle, circle, ellipse, or convex polygon. The result is always one of those containing shapes. In general it will not coincide exactly with the original shape unless that boundary already has the desired shape.
    – whuber
    Commented Nov 22, 2010 at 20:06

I know this is an old question, but I think the answer I just found was introduced since the previous ones here, so I'm sharing it for people who find this in a search.

QGIS (as of version 2.14 at least), has a "Fill Holes" in the Processing toolbox, under QGIS geoalgorithms > Vectory geometry tools. I find that dissolving shapes and then running Fill Holes with the Max area parameter set very high solves this problem.


You may also be looking for what used to be called DROPLINE functionality.

Although it did not survive the ArcInfo Workstation to ArcGIS Desktop transition, there is currently an ArcGIS Idea to have it restored:

It would be nice to have the option to drop the lines between polygons that have the same values for a specified field. This functionality used to be available in ArcPlot as the DROPLINE command and was widely used as a way to avoid creating a new dataset with the dissolve command.


You can use the ST_UNION function in PostGIS from QGIS DB Manager to aggregate all polygons in the layer (or many groups of polygons into larger polygons). From the documentation:

Variant 2 is an aggregate function that takes a set of geometries and unions them into a single ST_Geometry resulting in no intersecting regions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.