8

Some background: I have 2 polygon shape files with approximately 500,000 records each. The two files are identical in terms of field structure.

Using ArcGIS 10.0 I can'nt merge these two files using Geoprocessing / Merge. ArcMap allways crashes somewhere in the middle of the process.

Is there any open source software that can do this job? QGIS has the function: Vector/ Merging shape file into one , but there was a reported bug with this function in the current version 1.7. I know GDAL can do a lot of things and wonder if GDAL or some other opensource software can do this properly.

1
  • 4
    is there a chance that you are exceeding the 2 Gb limit for shapefiles?
    – user681
    Commented May 8, 2012 at 14:42

4 Answers 4

18

From the GDAL manual:

A merge of two shapefiles 'file1.shp' and 'file2.shp' into a new file 'file_merged.shp' is performed like this:

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

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.

http://www.gdal.org/ogr/drv_shapefile.html

5
  • 2
    --skipfailures makes sure you continue if you encounter a bad record, too. I would add it if the process is taking too long. Commented May 8, 2012 at 15:56
  • Thanks jzl5325, this is what I was looking for (beside the alternative to do it in ArcMap). I think there is a good demand for a task-oriented manual/userguide for GDAL rather than syntax. Something like the one in your answer that begin with a task: i.e. to merge 2 shp file, to convert from mapinfo tab to esri shp. A long list of "to do this with GDAL" will be very useful.
    – anh.hv
    Commented May 9, 2012 at 10:17
  • @anh.hv Agreed. Something I would love to do if I had a bit more time. I suspect that something like that will not happen until A)it is a part of some college coursework or B)It gets funded by a sponsor to GDAL.
    – Jay Laura
    Commented May 9, 2012 at 20:13
  • If you have many files to merge you could use a script like this: <!-- language: lang-bsh --> #!/bin/bash dest_dir="output" dest_layer="shape_file" mkdir -p "${dest_dir}" i=0 for src_file in source/*.shp ; do echo "${src_file}" if [ $i -eq 0 ] ; then ogr2ogr "${dest_dir}/${dest_layer}.shp" "${src_file}" else ogr2ogr -update -append "${dest_dir}/${dest_layer}.shp" "${src_file}" -nln "${dest_layer}" fi i=$((i+1)) done Commented Dec 17, 2015 at 5:59
  • If you have many files to merge you could use a script like this: gist.github.com/andrewharvey/09f1b77f64c6f529e266 Commented Dec 17, 2015 at 6:07
3

Try converting the shapefiles to a file geodatabase and then merge them in ArcGIS.

You may even be able to convert them back to shape after the merge (in case you're trying to maintain compatibility with other software that relies on shapefiles).

1
  • Thanks Kevin and @vadivelan. Putting shp into file geodatabase really work. It also reduce the sized of the merged file by 4 time compare to the 2 original shape files.
    – anh.hv
    Commented May 9, 2012 at 10:11
3

You could try Geomerge. I'm not sure how many records it can handle, but so long as the table structure is the same for all files I have not had any problems with it.

The MapBrowser available on the same website is also an excellent little tool for quick viewing of shapefiles without having to open up a GIS package.

1

As Kevin said converting the shape files into fGDB is the best option. (It will be very fast compared to shp files)

Because, Shape files have a limitation in the storage capacity, i think your two shapes files (after merge) is beyond this limit. Pls. check that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.