v.dissolve(1grass)
๐ v.dissolve โ GRASS User's Manual ๐
okay bestie, sit down, hydrate, and let me tell you about v.dissolve(1grass) because this one is so good. it's the module that takes all your adjacent or overlapping features that share a category number or attribute and just... merges them. iconic behavior honestly. ๐ซถ
โจ NAME โจ
v.dissolve โ Dissolves adjacent or overlapping features sharing a common category number or attribute.
๐ธ KEYWORDS ๐ธ
vector, dissolve, area, line
๐ฆ SYNOPSIS ๐ฆ
v.dissolve
v.dissolve --help
v.dissolve input=name [layer=string] [column=name] output=name
[aggregate_columns=name[,name,...]]
[aggregate_methods=string[,string,...]]
[result_columns=name[,name,...]] [aggregate_backend=string]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
๐ Flags
--overwriteโ Allow output files to overwrite existing files--helpโ Print usage summary--verboseโ Verbose module output--quietโ Quiet module output--uiโ Force launching GUI dialog
๐ Parameters
input=name[required] โ Name of input vector map. Or data source for direct OGR access.layer=stringโ Layer number or name. Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. Default:1.column=nameโ Name of attribute column used to dissolve features.output=name[required] โ Name for output vector map.aggregate_columns=name[,name,...]โ Names of attribute columns to get aggregate statistics for. One column name or SQL expression per method if result columns are specified.aggregate_methods=string[,string,...]โ Aggregate statistics method (e.g.,sum). Default is all available basic statistics for a given backend (for sql backend:avg,count,max,min,sum).result_columns=name[,name,...]โ New attribute column names for aggregate statistics results. Defaults to aggregate column name and statistics name and can contain type.aggregate_backend=stringโ Backend for attribute aggregation. Default issqlunless the provided aggregate methods are for univar. Options:sql,univar.sql: Uses SQL attribute databaseunivar: Usesv.db.univar
๐ DESCRIPTION ๐
So. The v.dissolve module is used to merge adjacent or overlapping features in a vector map that share the same category value. The resulting merged feature(s) retain this category value. periodt.
Figure: Areas with the same attribute value (first image) are merged into one (second image).
Instead of dissolving features based on the category values, the user can define an integer or string column using the column parameter. In that case, features that share the same value in that column are dissolved. Note, the newly created layer does not retain the category (cat) values from the input layer. ๐ซฃ
Note that multiple areas with the same category or the same attribute value that are not adjacent are merged into one entity, which consists of multiple features, i.e., a multipart feature. so yeah, they get bundled together whether they're neighbors or not, no vibe check required.
๐งฎ Attribute aggregation
The attributes of merged areas can be aggregated using various aggregation methods. The specific methods available depend on the backend used for aggregation. Two aggregate backends (specified with the aggregate_backend parameter) are available, univar and sql. The backend is determined automatically based on the requested methods. When the function is one of the SQL build-in aggregate functions, the sql backend is used. Otherwise, the univar backend is used.
The default behavior is intended for interactive use and testing. For scripting and other automated usage, explicitly specifying the backend with theaggregate_backendparameter is strongly recommended. When choosing, note that thesqlaggregate backend, regardless of the underlying database, will typically perform significantly better than theunivarbackend. ๐ฅ
๐ฌ Aggregation using univar backend
When univar is used, the methods available are the ones which v.db.univar uses by default, i.e., n, min, max, range, mean, mean_abs, variance, stddev, coef_var, and sum.
๐๏ธ Aggregation using sql backend
When the sql backend is used, the methods depend on the SQL database backend used for the attribute table of the input vector. For SQLite, there are at least the following built-in aggregate functions: count, min, max, avg, sum, and total. For PostgreSQL, the list of aggregate functions is much longer and includes, e.g., count, min, max, avg, sum, stddev, and variance.
๐ฏ Defining the aggregation method
If only the parameter aggregate_columns is provided, all the following aggregation statistics are calculated: n, min, max, mean, and sum. If the univar backend is specified, all the available methods for the univar backend are used.
The aggregate_methods parameter can be used to specify which aggregation statistics should be computed. Alternatively, the parameter aggregate_columns can be used to specify the method using SQL syntax. This provides the highest flexibility, and it is suitable for scripting. The SQL statement should specify both the column and the functions applied, e.g.,
aggregate_columns="sum(cows) / sum(animals)"
Note that when the aggregate_columns parameter is used, the sql backend should be used. In addition, the aggregate_columns and aggregate_methods cannot be used together. ๐
For convenience, certain methods, namely n, count, mean, and avg, are automatically converted to the appropriate name for the selected backend. However, for scripting, it is recommended to specify the appropriate method (function) name for the backend, as the conversion is a heuristic that may change in the future. bestie, don't build your whole pipeline on vibes that might shift. ๐
If the result_columns is not provided, each method is applied to each column specified by aggregate_columns. This results in a column for each of the combinations. These result columns have auto-generated names based on the aggregate column and method. For example, setting the following parameters:
aggregate_columns=A,B
aggregate_methods=sum,n
results in the following columns: A_sum, A_n, B_sum, B_n. See the Examples section.
If the result_column is provided, each method is applied only once to the matching column in the aggregate column list, and the result will be available under the name of the matching result column. For example, setting the following parameter:
aggregate_columns=A,B
aggregate_methods=sum,max
result_column=sum_a, n_b
results in the column sum_a with the sum of the values of A and the column n_b with the max of B. Note that the number of items in aggregate_columns, aggregate_methods (unless omitted), and result_column needs to match, and no combinations are created on the fly. See the Examples section.
For scripting, it is recommended to specify all resulting column names, while for interactive use, automatically created combinations are expected to be beneficial, especially for exploratory analysis. โจ
The type of the result column is determined based on the method selected. For n and count, the type is INTEGER and for all other methods, it is DOUBLE. Aggregate methods that produce other types require the type to be specified as part of the result_columns. A type can be provided in result_columns using the SQL syntax name type, e.g., sum_of_values double precision. Type specification is mandatory when SQL syntax is used in aggregate_columns (and aggregate_methods is omitted).
๐ NOTES ๐
GRASS defines a vector area as a composite entity consisting of a set of closed boundaries and a centroid. The centroids must contain a category number (see v.centroids), this number is linked to area attributes and database links.
Multiple attributes may be linked to a single vector entity through numbered fields referred to as layers. Refer to v.category for more details.
Merging of areas can also be accomplished using v.extract -d which provides some additional options. In fact, v.dissolve is simply a front-end to that module. The use of the column parameter adds a call to v.reclass before. ๐ง
๐ EXAMPLES ๐
okay bestie, this is the part where it all clicks. buckle up. ๐
โจ Basic use โจ
the simplest of simple. the vanilla of vanilla. and honestly? iconic.
v.dissolve input=undissolved output=dissolved
โจ Dissolving based on column attributes โจ
let's use the North Carolina data set for this one:
g.copy vect=soils_general,mysoils_general
v.dissolve mysoils_general output=mysoils_general_families column=GSL_NAME
so we copy it first, then dissolve it by GSL_NAME. cute. ๐
โจ Dissolving adjacent SHAPE files to remove tile boundaries โจ
okay so scenario: the tile boundaries of adjacent maps (think CORINE Landcover SHAPE files, iykyk) need to go away. that means an extra step is required to remove duplicated boundaries. not optional. the extra step is mandatory, bestie.
# patch tiles after import:
v.patch -e `g.list type=vector pat="clc2000_*" separator=","` out=clc2000_patched
# remove duplicated tile boundaries:
v.clean clc2000_patched out=clc2000_clean tool=snap,break,rmdupl thresh=.01
# dissolve based on column attributes:
v.dissolve input=clc2000_clean output=clc2000_final col=CODE_00
patch, clean, dissolve. the holy trinity of "why are there lines everywhere". ๐ฆ
โจ Attribute aggregation โจ
not me discovering we can also aggregate attribute values of the original features while dissolving?? obsessed.
let's aggregate the area in acres (ACRES) of all municipal boundaries (boundary_municp) in the full NC dataset, dissolving common boundaries based on the name in the DOTURBAN_N column. and yes, long lines get split with a backslash marking a continued line, exactly like in Bash:
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities \
aggregate_columns=ACRES
to inspect the result, we use v.db.select and grab just one row where DOTURBAN_N == 'Wadesboro':
v.db.select municipalities where="DOTURBAN_N == 'Wadesboro'" separator=tab
the resulting table may look like this:
cat DOTURBAN_N ACRES_n ACRES_min ACRES_max ACRES_mean ACRES_sum
66 Wadesboro 2 634.987 3935.325 2285.156 4570.312
so that gave us multiple columns for each of the statistics computed by default. which is a lot. we can limit the number of statistics computed by specifying the method that should be used:
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities_2 \
aggregate_columns=ACRES aggregate_methods=sum
and now you get a single column with the sum for all values in the ACRES column for each group of original features which had the same value in the DOTURBAN_N column and are now dissolved (merged) into one. chef's kiss. ๐
โจ Aggregating multiple attributes โจ
expanding on the previous example (yes we're building, that's the vibe), we can compute values for multiple columns at once by adding more columns to the aggregate_columns option. here we compute the average of values in the NEW_PERC_G column:
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities_3 \
aggregate_columns=ACRES,NEW_PERC_G aggregate_methods=sum,avg
by default, all methods specified in the aggregate_methods are applied to all columns, so the result of the above is four columns. ngl that's convenient when you want multiple statistics for similar columns (like averages and standard deviations of multiple population statistics columns), but in our case each column is different and each aggregate method should only be applied to its corresponding column. ๐
the v.dissolve module will apply each aggregate method only to the corresponding column when column names for the results are specified manually with the result_columns option:
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities_4 \
aggregate_columns=ACRES,NEW_PERC_G aggregate_methods=sum,avg \
result_columns=acres,new_perc_g
now we have full control over what columns are created ๐ซถ, but heads up, we also need to specify an aggregate method for each column even when the aggregate methods are the same:
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities_5 \
aggregate_columns=ACRES,DOTURBAN_N,TEXT_NAME aggregate_methods=sum,count,count \
result_columns=acres,number_of_parts,named_parts
while it is often not necessary to specify aggregate methods or names for interactive exploratory analysis, specifying both aggregate_methods and result_columns manually is a best practice for scripting (unless SQL syntax is used for aggregate_columns, see below ๐).
โจ Aggregating using SQL syntax โจ
the aggregation can also be done using the full SQL syntax and the set of aggregate functions available for a given attribute database backend. here, we will assume the default SQLite database backend for attribute. ๐
modifying the previous example, we now specify the SQL aggregate function calls explicitly instead of letting v.dissolve generate them for us. we will:
- compute sum of the
ACREScolumn usingsum(ACRES)(alternatively, we could use SQLite specifictotal(ACRES)which returns zero even when all values areNULL) - count the number of aggregated (i.e., dissolved) parts using
count(*)which counts all rows regardless ofNULLvalues - count all unique names of parts as distinguished by the
MB_NAMEcolumn usingcount(distinct MB_NAME) - collect all these names into a comma-separated list using
group_concat(MB_NAME)
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities_6 \
aggregate_columns="total(ACRES),count(*),count(distinct MB_NAME),group_concat(MB_NAME)" \
result_columns="acres REAL,named_parts INTEGER,unique_names INTEGER,names TEXT"
here, v.dissolve doesn't make any assumptions about the resulting column types, so we specified both the name and the type of each column. noted. โ๏ธ
when working with general SQL syntax, v.dissolve turns off its checks for number of aggregate and result columns to allow for all SQL syntax to be used for aggregate columns. this allows us to use functions with multiple parameters too, for example specifying a separator to be used with group_concat:
v.dissolve input=boundary_municp column=DOTURBAN_N output=municipalities_7 \
aggregate_columns="group_concat(MB_NAME, ';')" \
result_columns="names TEXT"
to inspect the result, we'll use v.db.select retrieving only one row for DOTURBAN_N == 'Wadesboro':
v.db.select municipalities_7 where="DOTURBAN_N == 'Wadesboro'" separator=tab
the resulting table may look like this:
cat DOTURBAN_N names
66 Wadesboro Wadesboro;Lilesville
look at that little semicolon doing its thing. slay. โจ
๐ธ SEE ALSO ๐ธ
v.category,v.centroids,v.extract,v.reclass,v.db.univar,v.db.select
๐ AUTHORS ๐
- M. Hamish Bowman, Department of Marine Science, Otago University, New Zealand (module)
- Markus Neteler (column support)
- Trevor Wiens (help page)
- Vaclav Petras, NC State University, Center for Geospatial Analytics, GeoForAll Lab (aggregate statistics)
๐ง SOURCE CODE ๐ง
Available at: v.dissolve source code (history)
Latest change: Saturday Oct 11 04:38:40 2025 in commit: 3dd71f5fab83b72a2db2da959fe075c5b3b52200
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
and that's a wrap bestie ๐ this whole page lives in the GRASS 8.5.0 Reference Manual, ยฉ 2003-2026 GRASS Development Team, and our girl v.dissolve(1grass) is documented right at GRASS 8.5.0 like the icon she is. go dissolve something. ๐๐ฆโจ
๐ฆ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 ยท GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms