[gdal-dev] Dissolve shapefile using GDAL/OGR

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Tue Feb 26 06:16:02 PST 2013


Hugo Benicio <hbobenicio <at> gmail.com> writes:

> 
> Hi!
> So, My question is pretty simple.
> I'm developing a software in C++ that uses GDAL/OGR library to handle
geoprocessing computations. What I need to do now is to dissolve a shapefile by
a column (similiar to the Quantum GIS tool "Vector > Geoprocessing Tools >
Dissolve").
> Does GDAL/OGR already support this operation (or eases this somehow)? Do I
have to implement it by myself? Do I need to use another library to easily
acomplish this task? (GRASS?).

Sure at least to some extent. The following command is utilising Spatialite SQL
and it is building unions by attribure "YTA". I suppose GDAL needs to be build
with Spatialite and Spatialite with GEOS. I tested with GDAL-dev Windows build
from gisinternals.com.

Test with ogrinfo

C:\GDAL_dev>ogrinfo  union_test.shp -dialect sqlite 
-sql "select ST_union(Geometry),YTA from union_test GROUP BY YTA"

Conversion into shapefile

C:\GDAL_dev>ogr2ogr -f "ESRI Shapefile" union.shp union_test.shp -dialect sqlite 
-sql "select ST_union(Geometry),YTA from union_test GROUP BY YTA"


-Jukka Rahkonen-




More information about the gdal-dev mailing list