OGRMERGE(1)

πŸ“¦
version 3.4.3 Β· 2 versions
, in epel 9

πŸ’… OGRMERGE(1) β€” the ogrmerge girlies' guide ✨

okay so this is a GDAL manpage, bestie, and it's literally the whole ogrmerge situation, explained with love 🫢


🌸 NAME 🌸

ogrmerge β€” merge several vector datasets into a single one. that's it. that's the vibe πŸ’–


✨ SYNOPSIS ✨

ogrmerge.py -o out_dsname src_dsname [src_dsname]*
            [-f format] [-single] [-nln layer_name_template]
            [-update | -overwrite_ds] [-append | -overwrite_layer]
            [-src_geom_type geom_type_name[,geom_type_name]*]
            [-dsco NAME=VALUE]* [-lco NAME=VALUE]*
            [-s_srs srs_def] [-t_srs srs_def | -a_srs srs_def]
            [-progress] [-skipfailures] [--help-general]

and the options that only exist when you're in your -single era πŸ‘‘:

[-field_strategy FirstLayer|Union|Intersection]
[-src_layer_field_name name]
[-src_layer_field_content layer_name_template]

πŸ¦‹ DESCRIPTION πŸ¦‹

New in version 2.2. ✨

So ogrmerge.py is this script that takes a bunch of vector datasets as input β€” each one has one or several vector layers β€” and copies them into a target dataset. iconic behavior, no notes.

there are essentially two modes, and you need to pick your fighter:

  • the default one, where each input vector layer gets copied as a separate layer into the target dataset. very "everyone gets their own little spot" energy πŸŽ€
  • the other one, turned on with the -single switch, where the content of all the input vector layers gets appended into a single target layer. this one lowkey assumes the schema of those vector layers is more or less the same. iykyk πŸ™ˆ

Internally this generates a vector.vrt file, and if the output format is not VRT, the final translation is done with ogr2ogr or gdal.VectorTranslate(). so for your advanced little experiments, you can output to VRT, potentially edit it by hand, and then run ogr2ogr. main character workflow honestly πŸ’…

πŸ’– The options, one by one πŸ’–

  • -o <out_dsname> β€” Output dataset name. Required. not optional, bestie.
  • <src_dsname> β€” One or several input vector datasets. also Required 😭
  • -f <format> β€” Select the output format. starting with GDAL 2.3, if you don't specify it, the format is guessed from the extension (before that it was ESRI Shapefile, rip to the old days). Use the short format name ✨
  • -single β€” If specified, all input vector layers will be merged into a single one. the "everyone squeeze into the group photo" option 🫢
  • -nln <layer_name_template> β€” Name of the output vector layer (in single mode, and the default is "merged"), or a template to name the output vector layers in default mode (the default value is {AUTO_NAME}). The template can be a string with the following variables that will be susbstitued with a value computed from the input layer being processed:
    • {AUTO_NAME}: equivalent to {DS_BASENAME}_{LAYER_NAME} if both values are different, or {LAYER_NAME} when they are identical (case of shapefile). 'different
    • {DS_NAME}: name of the source dataset
    • {DS_BASENAME}: base name of the source dataset
    • {DS_INDEX}: index of the source dataset
    • {LAYER_NAME}: name of the source layer
    • {LAYER_INDEX}: index of the source layer
  • -update β€” Open an existing dataset in update mode. gently. respectfully. 🧚
  • -overwrite_ds β€” Overwrite the existing dataset if it already exists (for file based datasets). no survivors πŸ’€
  • -append β€” Open an existing dataset in update mode, and if output layers already exist, append the content of input layers to them. adding to the pile πŸ“
  • -overwrite_layer β€” Open an existing dataset in update mode, and if output layers already exist, replace their content with the one of the input layer. out with the old, in with the new ✨
  • -src_geom_type <geom_type_name[,geom_type_name]\*]> β€” Only take into account input layers whose geometry type match the type(s) specified. Valid values for geom_type_name are GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CIRCULARSTRING, CURVEPOLYGON, MULTICURVE, MULTISURFACE, CURVE, SURFACE, TRIANGLE, POLYHEDRALSURFACE and TIN. yes that's the whole roster, we don't gatekeep 🌈
  • -dsco <NAME=VALUE> β€” Dataset creation option (format specific) πŸ’œ
  • -lco <NAME=VALUE> β€” Layer creation option (format specific) πŸ’œ
  • -a_srs <srs_def> β€” Assign an output SRS πŸŽ€
  • -t_srs <srs_def> β€” Reproject/transform to this SRS on output πŸŒ€
  • -s_srs <srs_def> β€” Override source SRS πŸŒ€
  • -progress β€” Display progress on terminal. Only works if input layers have the "fast feature count" capability. so if you get nothing, that's why, don't come for her 😭
  • -skipfailures β€” Continue after a failure, skipping the failed feature. resilience queen πŸ‘‘

🌟 the -single-only section 🌟

  • -field_strategy FirstLayer|Union|Intersection β€” Only used with -single. Determines how the schema of the target layer is built from the schemas of the input layers. May be FirstLayer to use the fields from the first layer found, Union to use a super-set of all the fields from all source layers, or Intersection to use a sub-set of all the common fields from all source layers. Defaults to Union. 🫢
  • -src_layer_field_name <name> β€” Only used with -single. If specified, the schema of the target layer will be extended with a new field name, whose content is determined by -src_layer_field_content. ✨
  • -src_layer_field_content <layer_name_template> β€” Only used with -single. If specified, the schema of the target layer will be extended with a new field (whose name is given by -src_layer_field_name, or 'source_ds_lyr' otherwise), whose content is determined by layer_name_template. The syntax of layer_name_template is the same as for -nln. πŸ’«

πŸŽ€ EXAMPLES πŸŽ€

Create a VRT with a layer for each input shapefiles β€” vrt era, we love a lightweight moment:

ogrmerge.py -f VRT -o merged.vrt *.shp

Same, but creates a GeoPackage file β€” ok now we're being fancy:

ogrmerge.py -f GPKG -o merged.gpkg *.shp

Concatenate the content of france.shp and germany.shp in merged.shp, and adds a 'country' field to each feature whose value is 'france' or 'germany' depending where it comes from. β€” literally the "who are you and where do you come from" feature:

ogrmerge.py -single -o merged.shp france.shp germany.shp -src_layer_field_name country

πŸ‘‘ AUTHOR πŸ‘‘

Even Rouault <even.rouault@spatialys.com> β€” legend behavior, fr fr πŸ’œ


1998-2026


and that's the page bestie πŸ¦‹ this was GDAL's ogrmerge, dated Jan 08, 2026, and honestly? she ate πŸ’…βœ¨ go merge something iconic 🫢

πŸ“¦ where this page comes from