dissolve/2: merge rows that share a key into one row, like geopandas.GeoDataFrame.dissolve.
How rows stay aligned
Group ids are computed once on the Elixir side from the key columns, one dense id per row,
numbered in result order (sorted key order, or first appearance with sort: false). The
same ids drive both halves:
- the geometry:
GeoFrame.GeoSeries.union_groups/3unions each group in one NIF call and returns one row per id; - the attributes: a temporary id column is grouped and summarised with Explorer, then sorted by id.
So result row i of the attributes and of the geometry always describe group i.
Result
Group keys are kept as leading columns (GeoPandas makes them the index), followed by the remaining attributes. Nulls sort last, as in GeoPandas.
Summary
Functions
Dissolves gdf by key columns.
Functions
@spec dissolve(GeoFrame.GeoDataFrame.t(), keyword()) :: GeoFrame.GeoDataFrame.t()
Dissolves gdf by key columns.
Options:
:by- a column name (string or atom) or a list of names;nil(default) dissolves everything into a single row.:aggfunc-:first(default),:last,:sum,:mean,:min,:maxor:count, applied to every non-key attribute (numeric functions raise on non-numeric columns, so list the columns explicitly for mixed frames); or a keyword list / map of column to function, in which case only the listed columns are kept (after the keys). Secondary geometry columns are aggregated like the other columns, but only:first,:last(the first / last non-null geometry of the group, keeping the column's CRS) and:count(an integer attribute) apply to geometry: any other function raisesArgumentError, as GeoPandas raisesTypeError. Dissolving by a geometry column raisesArgumentError.:dropna-true(default) drops rows with a null key;falsekeeps them as a group.:sort-true(default) orders groups by key,falseby first appearance.:observed- for:categorykey columns only.true(default) keeps the groups that occur in the data;falsealso adds every unobserved combination of the keys' values as an empty group, likeobserved=Falsein GeoPandas: the geometry isGEOMETRYCOLLECTION EMPTY,:sumand:countgive 0 and the other functions null. Each key's levels are the values it holds: Explorer categoricals share one process-wide category mapping, so a column has no categories of its own beyond its values, and categories with no rows (which pandas can declare) are not added; with one key the option therefore adds nothing. Groups are ordered by key text; withsort: falseeach key's values come in order of appearance. Without category keys the option has no effect; mixing category and other keys raisesArgumentError. GeoPandas defaults tofalse; the default here staystrueso existing calls keep their result.:as_index- accepted for parity. There is no index: the keys are always leading columns, which is whatas_index=Falsegives in GeoPandas (except that the geometry column is last).falseis a no-op;trueraisesArgumentError.:level- not supported (no index levels); raisesArgumentError.
Geometries of a group are merged with GeoFrame.GeoSeries.union_all/1 semantics (null
geometries skipped). The CRS is preserved. Raises ArgumentError for unknown columns or
aggregation functions, or when a key is the geometry column.