Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to open a USGS KML file of bedrock geology for an entire county, but there are over 2,000 individual polygon layers. Does anyone know if there is a way to merge all of these layers together into one file before opening in QGIS?

share|improve this question
Your initial statement is a bit confusing. Do you have one kml file with multiple polygons in it, or do you have 2000 individual kml files representing the bedrock geology types? – Get Spatial Jul 22 '12 at 20:31
One thing you might do is use python and the QGIS API to do it. This question and answer provides a means to get started: How to write standalone Python scripts using QGIS – Get Spatial Jul 22 '12 at 20:32
Yes it is one kml file with multiple polygon files. I was hoping for a plugin, because I know nothing about programming with python, but maybe now is a good time to start learning! Thanks. – Patrick Jul 23 '12 at 15:55
I am not sure I understand, if I have a kml file with multiple lines, that would just open as one layer with multiple lines in QGIS. If on the other hand you have multiple kml files, you can open them all in Google earth, put them in one folder and export the folder as a new kml. – Paulo Aug 1 '12 at 7:38

Here a simple shell script ("") which uses ogr2ogr:


# Markus Neteler, 2008
# merge KML files

PROG=`basename $0`

if [ $# -lt 1 ] ; then
 echo "Merges KML files together (mosaik)"
 echo "Usage:"
 echo "  $PROG *.kml"
 echo "  $PROG a.kml b.kml c.kml"
 echo "At then end of the merge you can select a new name"
 exit 1


rm -f $OUT.kml

ogr2ogr -f KML $OUT.kml $1

for i in `seq 1 $#` ; do
  echo "Appending #$i: $1"
  ogr2ogr -f KML -update -append $OUT.kml $1 -nln $OUT `basename $1 .kml`

echo "Written: $OUT.kml"

echo -n "Enter file name for new KML (or CTRL-C): "
read NEW
NEW=`basename $NEW .kml`
mv $OUT.kml $NEW.kml

echo "Written as: $NEW.kml"

Hope this gives the idea.

share|improve this answer

One option would be to write a "wrapper" KML file and include links to each file in the wrapper, using the KML NetworkLink. Although it says "network", the Link element can contain a local file path instead. You can also use this in a KMZ structure

share|improve this answer
@ BradHards your link "KMZ structure" is not working any more. – SIslam May 25 '15 at 5:45
@SIslam: the link has been updated. – BradHards May 25 '15 at 11:09

Create a folder in which you'll then add the individual kml/kmz files. Go to Save as and in your destination, save this folder as a kml.Your result will be a single kml file. Hope this helps

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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