GDAL-VECTOR-EXPORT-SCHEMA(1)

πŸ“¦ version 3.13.3, in alpine 3.24, arch rolling, ubuntu stonking

✨ GDAL-VECTOR-EXPORT-SCHEMA(1) ✨

okay bestie, welcome to the gdal-vector-export-schema(1) page of the GDAL manual πŸ’– this is the one that yanks the OGR_SCHEMA out of your vector dataset and hands it to you like a lil gift. let's get into it πŸŽ€


🌸 NAME 🌸

gdal-vector-export-schema β€” Export the OGR_SCHEMA from a vector dataset

Added in version 3.13. πŸ¦‹


⭐ SYNOPSIS ⭐

Usage: gdal vector export-schema [OPTIONS] <INPUT>...

Export the OGR_SCHEMA from a vector dataset.

Positional arguments:
  -i, --dataset, --input <INPUT>            Input vector datasets [may be repeated] [required]

Common Options:
  -h, --help                                Display help message and exit
  --json-usage                              Display usage as JSON document and exit
  --config <KEY>=<VALUE>                    Configuration option [may be repeated]

Options:
  -l, --layer, --input-layer <INPUT-LAYER>  Input layer name [may be repeated]

Advanced Options:
  --oo, --open-option <KEY>=<VALUE>         Open options [may be repeated]
  --if, --input-format <INPUT-FORMAT>       Input formats [may be repeated]

πŸ’… DESCRIPTION πŸ’…

so gdal vector export-schema exports the OGR_SCHEMA from a GDAL-supported vector dataset, and it returns it on the standard output stream when you're using it from the command line β€” or in the output parameter when you're using it from the API. either way you're getting your schema, no cap 🫢

OGR_SCHEMA is a JSON object describing the structure of a vector dataset according to the schema definition at ogr_fields_override.schema.json.

and here's the iconic part: gdal vector export-schema can be used as the last step of a pipeline πŸ‘‘

The following options are available:


πŸŽ€ PROGRAM-SPECIFIC OPTIONS πŸŽ€

  • -l, --layer, --input-layer <INPUT-LAYER> β€” Name of one or more layers to inspect. If no layer names are passed, then all layers will be selected. she's not picky unless you tell her to be πŸ’–

🌈 STANDARD OPTIONS 🌈

  • --oo, --open-option <NAME>=<VALUE> β€” Dataset open option (format specific).

May be repeated.

  • --if, --input-format <format> β€” Format/driver name to be attempted to open the input file(s). It is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. This option can be repeated several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions. πŸ™ˆ

May be repeated.


πŸ”₯ RETURN STATUS CODE πŸ”₯

The program returns status code 0 in case of success, and non-zero in case of error (non-blocking errors emitted as warnings are considered as a successful execution). so like, a lil warning isn't a fail, it's just a vibe check that didn't pass perfectly, but we move πŸ’…


πŸ¦‹ EXAMPLES πŸ¦‹

Example 1: Extracting the OGR_SCHEMA from the file poly.gpkg

gdal vector export-schema poly.gpkg

Example 2: Save the OGR_SCHEMA to a file

When using Windows PowerShell 5.1, redirecting output with > or Out-File -Encoding utf8 produces UTF-8 with a BOM (Byte Order Mark). When using the schema with gdal vector create it may fail with ERROR 1: JSON parsing error: unexpected character (at offset 0). 😭 not the BOM jump scare

In PowerShell 5.1, use -Encoding ascii for JSON output that contains no non-ASCII characters. 🫢

Bash

gdal vector export-schema natural_earth_vector.gpkg --layer "ne_50m_admin_0_countries" > countries.json

PowerShell

# PowerShell 5.1
gdal vector export-schema natural_earth_vector.gpkg --layer "ne_50m_admin_0_countries" | Out-File countries.json -Encoding ascii

# PowerShell 7+
gdal vector export-schema natural_earth_vector.gpkg --layer "ne_50m_admin_0_countries" | Out-File countries.json -Encoding utf8

Example 3: Validate an OGR_SCHEMA file using Python

Validate against the latest version of the schema definition at ‐ ogr_fields_override.schema.json using the Python package ‐ check-jsonschema available on PyPI.

$ pip install check-jsonschema
$ check-jsonschema --schemafile https://raw.githubusercontent.com/OSGeo/gdal/master/ogr/data/ogr_fields_override.schema.json countries.json --verbose

Example 4: Create an OGR_SCHEMA at the end of a pipeline

This example renames the field pop_est to estimated_population and changes its type from Real to Integer, before exporting the resulting OGR_SCHEMA. πŸ’«

Bash

gdal vector pipeline \
    ! read natural_earth_vector.gpkg --layer ne_50m_admin_0_countries \
    ! sql --sql "SELECT geom,name,abbrev,pop_est AS estimated_population FROM ne_50m_admin_0_countries" --output-layer "countries" \
    ! set-field-type --field-name "estimated_population" --field-type Integer \
    ! export-schema

PowerShell

gdal vector pipeline `
    ! read natural_earth_vector.gpkg --layer ne_50m_admin_0_countries `
    ! sql --sql "SELECT geom,name,abbrev,pop_est AS estimated_population FROM ne_50m_admin_0_countries" --output-layer "countries" `
    ! set-field-type --field-name "estimated_population" --field-type Integer `
    ! export-schema

the pipeline is giving main character energy for real, she's stacking operations like accessories πŸ”₯


πŸ’œ AUTHOR πŸ’œ

Alessandro Pasotti <elpaso@itopen.it>


1998-2026


okay that's the whole page bestie, you ate it up πŸ’…βœ¨ this was the GDAL manual page GDAL-VECTOR-EXPORT-SCHEMA(1) from the GDAL source, dated Aug 18, 2026 β€” go export some schemas, ily, periodt πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from