OGR_LAYER_ALGEBRA(1)

🌸 NAME 🌸

ogr_layer_algebra β€” bestie, it does ALL the Vector layer algebraic operations for you, no cap πŸ’…

Added in version 3.6. ✨


πŸ“œ SYNOPSIS πŸ“œ

   ogr_layer_algebra [--help] [--help-general]
                       Union|Intersection|SymDifference|Identity|Update|Clip|Erase
                       -input_ds <path> [-input_lyr <name>]
                       -method_ds <path> [-method_lyr <name>]
                       -output_ds <path> [-output_lyr <name>] [-overwrite]
                       [-opt <NAME>=<VALUE>]...
                       [-f <format_name>] [-dsco <NAME>=<VALUE>]... [-lco <NAME>=<VALUE>]...
                       [-input_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}] [-method_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>}]
                       [-nlt <geom_type>] [-a_srs <srs_def>]

🧠 DESCRIPTION 🧠

okay so ogr_layer_algebra is a command line utility that lets you do all kinds of Vector layer algebraic operations, and it literally eats every time 🫢. You hand it a vector input source and a method source, and it drops the result of your operation straight into the output file you picked.

NOTE: ogr_layer_algebra is a Python utility, and it's only available if GDAL Python bindings are available. So if your bindings aren't there… yeah, it's not coming to the party 😭.
TIP: equivalent in the new gdal command line interface: gdal vector layer-algebra. πŸ‘‘

  • --help β€” shows you this help message and dips. ✌️
  • --help-general β€” gives you a lil brief usage message for the generic GDAL commandline options, then exits. short and sweet fr fr.
  • <mode> β€” where <mode> is one of the seven available modes, and babes, it's a whole menu:
    • Union β€” a union is a set of features that represent areas which are in either of the operand layers. both? say less. πŸ’–
    • Intersection β€” an intersection is a set of features representing the common areas of two layers. the overlap, the shared moment, the we-both-vibe 🌸
    • SymDifference β€” a symmetric difference is a set of features representing areas that are in the operand layers but which do not intersect. it's giving "opposites attract" πŸ’€
    • `Identity`` β€” the identity method identifies features in the input layer with features in the method layer, possibly splitting features into several features. By default the result layer has attributes from both operand layers. πŸŽ€
    • Update β€” the update method creates a layer which adds features into the input layer from the method layer, possibly cutting features in the input layer. By default the result layer has attributes only from the input layer. ✨
    • Clip β€” the clip method creates a layer which has features from the input layer clipped to the areas of the features in the method layer. By default the result layer has attributes of the input layer. βœ‚οΈ iconic.
    • Erase β€” the erase method creates a layer which has features from the input layer whose areas are erased by the features in the method layer. By default the result layer has attributes of the input layer. 🧼
  • -input_ds <path> β€” the input dataset path where the operation happens. For operations involving two datasets, this is one of the datasets. one of the mains πŸ’…
  • -input_lyr <name> β€” layer name of the input_ds that the operations have to be performed on. Optional, no pressure πŸ¦‹
  • -method_ds <path> β€” method data set path for the operation. This is usually the conditional data set supplied to the operation (ex: clip, erase, update). This is the second data set in the operation (ex: Union, Intersection, SymDifference). the supporting character that's honestly lowkey the main character 🌈
  • -method_lyr <name> β€” layer name of the method_ds for which the operations have to be performed. Optional πŸ’œ
  • -output_ds <path> β€” output data set path where the result of the operations performed by ogr_layer_algebra gets written. the moment we've all been waiting for ⭐
  • -output_lyr_name <name> β€” layer name of the output_lyr_name where the output vector has to be written. Optional. (heads up: the synopsis up top calls this -output_lyr β€” ik, ik πŸ™ˆ)
  • -overwrite β€” indicates whether the output_ds has to be overwritten with the generated result of ogr_layer_algebra. yes bestie we are replacing it, periodt.
  • -opt <NAME>=<VALUE> β€” attributes for which the operation has to run on input_ds and method_ds. πŸŽ€
  • -f <format_name> β€” select the output format. If not specified, the format is guessed from the extension (previously was ESRI Shapefile). Use the short format name. πŸ”₯
  • -dsco <NAME>=<VALUE> β€” dataset creation option (format specific). 🧚
  • -lco <NAME>=<VALUE> β€” layer creation option (format specific). 🌸
  • -input_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>} β€” comma-delimited list of fields from the input layer to copy to the output layer, if eligible according to the operation. ✨
  • -method_fields {NONE|ALL|<fld1>,<fl2>,...<fldN>} β€” comma-delimited list of fields from the method layer to copy to the output layer, if eligible according to the operation. πŸ¦‹
  • -nlt <geom_type> β€” define the geometry type for the created layer. One of NONE, GEOMETRY, POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION, MULTIPOINT, MULTIPOLYGON, GEOMETRY25D, POINT25D, LINESTRING25D, POLYGON25D, GEOMETRYCOLLECTION25D, MULTIPOINT25D, MULTIPOLYGON25D. pick your fighter πŸ’…
  • -a_srs <srs_def> β€” assign an output SRS, but without reprojecting. 🚨 no reprojection happening here, she's just labeling, not moving.

The coordinate reference systems that can be passed are anything supported by the OGRSpatialReference.SetFromUserInput() call, which includes EPSG Projected, Geographic or Compound CRS (i.e. EPSG:4296), a well known text (WKT) CRS definition, PROJ.4 declarations, or the name of a .prj file containing a WKT CRS definition. so many options and all of them valid, we love range πŸ’œ


🚦 RETURN STATUS CODE 🚦

the program returns status code 0 in case of success, and non-zero in case of error. and bestie, listen β€” non-blocking errors emitted as warnings are considered a successful execution, so don't spiral over those πŸ’–


1998-2026 β€” that's the whole section, she's concise. πŸ‘‘


and that's the tea, bestie πŸ“ this was OGR_LAYER_ALGEBRA(1) from the GDAL crew, dated Aug 18, 2026, with copyright living in 1998-2026. go clip something iconic, ily, bye πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from