Selon Paul Meems <[email protected]>: > Hi all, > > How can I union several shapefiles into one using ogr? > I tried using the OGR Virtual Format and created a XML file similar to this: > > <OGRVRTDataSource> > <OGRVRTUnionLayer name="unionLayer"> > <OGRVRTLayer name="source1"> > <SrcDataSource>source1.shp</SrcDataSource> > </OGRVRTLayer> > <OGRVRTLayer name="source2"> > <SrcDataSource>source2.shp</SrcDataSource> > </OGRVRTLayer> > </OGRVRTUnionLayer> > </OGRVRTDataSource> > > My next step was to call ogr2ogr to created the new file. > The above XML merges all shapes instead of performing an union.
This depends on how you define union. In the OGR VRT, the UNION is similar to the SQL UNION keyword, that is to say that the features of source2 will be appended after the features of source1 > How can I do a proper union using ogr? If you rather need a geometrical union ( ST_Union() ), then you can have a look at Spatialite (through SQL SQLite dialect for example : http://www.gdal.org/ogr/ogr_sql_sqlite.html ), or use the new OGR layer algebra operations (see http://www.gdal.org/ogr/ogr__api_8h.html#ac8edb8696c2b046370e29efdd73787f7 ) > > Thanks, > > Paul > _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
