[gdal-dev] ogr2ogr, Possible to control layer combining?

Frank Warmerdam warmerdam at p...
Thu Jul 18 17:09:26 EDT 2002


Frank Warmerdam wrote:
> Because the MapInfo OGR driver does not support appending to an existing
> dataset, this is pretty hard. I will look at modifying the shapefile
> driver to support layer append, and then - hopefully - you would be able
> to merge you different shapefiles into one shapefile, and then convert
> that to mapinfo. Of course, many other GIS tools provide some sort of
> merge option too.

Dan,

OK, it seems that recent OGRs will support merging shapefiles already.
Lets say you have two shapefiles file1.shp and file2.shp and you want to
merge them into file_merged.shp before converting to mapinfo. You can
do something like this:

ogr2ogr file_merged.shp file1.shp
ogr2ogr -update -append file_merged.shp file2.shp -nln file_merged file2

The second command is opening file_merged.shp in update mode, and trying to
find existing layers and append the features being copied.

The -nln option sets the name of the layer to be copied to.

Some of the -update and -append stuff was done since the GDAL/OGR 1.1.7
release, so you may need to update from CVS if you want to do this.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at p...
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent






More information about the Gdal-dev mailing list