The availability of physical memory may limit the amount (and complexity) of input features that can be processed and dissolved into a single output feature. This limitation could cause an error to occur, as the dissolve process may require more memory than is available. To prevent this, Dissolve may divide and process the input features using an adaptive tiling algorithm. To determine the features that have been tiled, run the Frequency tool on the result of this tool, specifying the same fields used in the dissolve process for the Frequency Field(s) parameter. Any record with a frequency value of 2 has been tiled. Tile boundaries are preserved in the output features to prevent the creation of features that are too large to be used by ArcGIS.
Caution:
Search ArcGIS Pro help. Delete features and parts of features. In this topic. Delete a feature; Delete a part of a multipart feature; When you select features in a map, you can delete them by pressing the Delete key, clicking Delete on the Edit tab in the Selection group, or right-clicking the map and using the context menu.
Running Dissolve on the output of a previous dissolve run will rarely reduce the number of features in the output when the original processing divided and processed the inputs using adaptive tiling. The maximum size of any output feature is determined by the amount of available memory at run time; therefore, output containing tiles is an indicator that dissolving any further with the available resources would cause an out-of-memory situation or result in a feature that is unusable. Additionally, running the Dissolve tool a second time on output that was created this way may result in very slow performance for little to no gain and may cause an unexpected failure.
Learning Objectives
After completing this tutorial, you will be able to:
- Aggregate the geometry of spatial data using
dissolve
based on an attribute inPython
- Aggregate the quantitative values in your attribute table when you perform a dissolve in
Python
What You Need
You will need a computer with internet access to complete this lesson and the spatial-vector-lidar data subset created for the course.
In this lesson, you will use
Python
to aggregate (i.e. dissolve) the spatial boundaries of the United States state boundaries using a region name that is an attribute of the dataset. Then, you will aggregate the values in the attribute table, so that the quantitative values in the attribute table will reflect the new spatial boundaries for regions.Import Packages and Data
To get started,
import
the packages you will need for this lesson into Python
and set the current working directory.Dissolve Polygons Based On an Attribute with Geopandas
Dissolving polygons entails combining polygons based upon a unique attribute value and removing the interior geometry.
Below you will dissolve the US states polygons by the region that each state is in. When you dissolve, you will create a new set polygons - one for each region in the United States.
To begin, explore your data. Using
.geom_type
you can see that you have a mix of single and multi polygons in your data. Sometimes multi-polygons can cause problems when processing. It’s always good to check your geometry before you begin to better know what you are working with.Next, select the columns that you with to use for the dissolve and that will be retained.
In this case, we want to retain the columns:
- region
- geometry
geometry | |
---|---|
region | |
Midwest | (POLYGON Z ((-82.863342 41.693693 0, -82.82571... |
Northeast | (POLYGON Z ((-76.04621299999999 38.025533 0, -... |
Southeast | (POLYGON Z ((-81.81169299999999 24.568745 0, -... |
Southwest | POLYGON Z ((-94.48587499999999 33.637867 0, -9... |
West | (POLYGON Z ((-118.594033 33.035951 0, -118.540... |
And finally, plot the data. Note that when you dissolve, the column used to perform the dissolve becomes an index for the resultant geodataframe. Thus, you will have to use the reset_index() method when you plot, to access the
region
column.If you do not reset the index, the following will return and error, as region is no longer a column, it is an index!
us_regions.plot(column = 'region', ax=ax)
You can use
us_regions.reset_index().plot(column = 'region', ax=ax)
to reset the index when you plot the data.Dissolve and Aggregate Data Attributes
In the example above, you dissolved the state level polygons to a region level. However, you did not aggregate or summarize the attributes associated with each polygon.
Next, you will learn how to aggregate quantitative values in your attribute table when you perform a dissolve. To do this, you will add
aggfunc = 'summaryfunction'
to your dissolve call.You can choice a suite of different summary functions including:
- first
- last
- mean
- max
And more. Read more about the dissolve function here.
Aggregate the data using the ‘sum’ method on the ALAND and AWATER attributes (total land and water area).
The values for ALAND and AWATER will be added up for all of the states in a region. Those new summed values will be returned in the new dataframe.
geometry | ALAND | AWATER | |
---|---|---|---|
region | |||
Midwest | (POLYGON Z ((-82.863342 41.693693 0, -82.82571... | 1943869253244 | 184383393833 |
Northeast | (POLYGON Z ((-76.04621299999999 38.025533 0, -... | 869066138232 | 108922434345 |
Southeast | (POLYGON Z ((-81.81169299999999 24.568745 0, -... | 1364632039655 | 103876652998 |
Southwest | POLYGON Z ((-94.48587499999999 33.637867 0, -9... | 1462631530997 | 24217682268 |
West | (POLYGON Z ((-118.594033 33.035951 0, -118.540... | 2432336444730 | 57568049509 |
Optional Challenge 1
Create a quantile map using the AWATER attribute column.
Optional Challenge 2
Aggregate the data using the ‘mean’ method on the ALAND and AWATER attributes (total land and water area). Then create two maps:
- a map of mean value for ALAND by region and
- a map of mean value for AWATER by region