Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

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 merge shapefiles of different geometry types into a single geojson feature collection, but OGR says it doesn't support update of GeoJSON files:

$ ogr2ogr -f GeoJSON -t_srs crs:84 -lco GEOMETRY_AS_COLLECTION merge.geojson points.shp
$ ogr2ogr -f GeoJSON -t_srs crs:84 -update -append merge.geojson -lco GEOMETRY_AS_COLLECTION lines.shp -nln merged
ERROR 4: GeoJSON Driver doesn't support update.
Unable to open existing output datasource `merge.geojson'.

This seems like a common use case to me. Am I missing something obvious in the ogr2ogr manual? I can put together something in python (and finally use fiona) but I'm rather surprised I don't see anything existing when searching here or github... which makes me thing I'm messing something up.


share|improve this question

Fortunately, OGR objects model does allow to have geometries of different types in single layer - a heterogeneous layer.


For instance, if we have three shapefiles of different geometry types (points.shp, lines.shp and polygons.shp) we can define the union layer using the OGR VRT driver specifying its geometry type as wkbGeometryCollection. So we can write the following VRT file, named i.e. merge.vrt:

    <OGRVRTUnionLayer name="union">
        <OGRVRTLayer name="points">
        <OGRVRTLayer name="lines">
        <OGRVRTLayer name="polygons">

Then, we can easily convert merge.vrt into merge.geojson, preserving all the attributes of the source layers, simply executing:

ogr2ogr -f GeoJSON merge.geojson merge.vrt

Finally, you can check if the conversion is done successfully:

ogrinfo merge.geojson OGRGeoJSON
share|improve this answer
Thanks, that answers the question. I didn't know about the VRT driver. I stopped using topojson and have been using merge-geojsons as recommended by another user, whos comment seems to be gone. – snorris Dec 3 '13 at 0:14

A modification of fiona's dumpgj to handle multiple inputs seemed to be the way to go.

I started - and was learning things - but then remembered that topojson accepts multiple inputs and it seems to work.

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.