GeoJSONSeq: sequence of GeoJSON features
Added in version 2.4.
Driver short name
GeoJSONSeq
Driver built-in by default
This driver is built-in by default
This driver implements read/creation support for features encoded individually as GeoJSON Feature objects, separated by newline (LF) (Newline Delimited JSON) or record-separator (RS) characters (RFC 8142 standard: GeoJSON Text Sequences)
Such files are equivalent to a GeoJSON FeatureCollection, but are more friendly for incremental parsing.
The driver automatically reprojects geometries to WGS84 longitude, latitude, if the layer is created with another SRS.
Appending to an existing file is supported since GDAL 3.6
Driver capabilities
Supports Create()
This driver supports the GDALDriver::Create()
operation
Supports Georeferencing
This driver supports georeferencing
Supports VirtualIO
This driver supports virtual I/O operations (/vsimem/, etc.)
Datasource
The driver accepts three types of sources of data:
Uniform Resource Locator (URL) - a Web address to perform HTTP request
Plain text file with GeoJSON data - identified from the file extension .geojsonl or .geojsons
Text passed directly as filename, and encoded as GeoJSON sequences
The URL/filename/text might be prefixed with GeoJSONSeq: to avoid any
ambiguity with other drivers. Alternatively, starting
with GDAL 3.10, specifying the -if GeoJSONSeq
option to command line utilities
accepting it, or GeoJSONSeq
as the only value of the papszAllowedDrivers
of
GDALOpenEx()
, also forces the driver to recognize the passed
URL/filename/text.
Configuration options
Configuration options can be specified in command-line tools using the syntax --config <NAME>=<VALUE>
or using functions such as CPLSetConfigOption()
(C) or gdal.config_options
(Python).
The following configuration option is available:
OGR_GEOJSON_MAX_OBJ_SIZE=<MBytes>: (GDAL >= 3.0.2) Defaults to
200
. size in MBytes of the maximum accepted single feature, or 0 to allow for a unlimited size (GDAL >= 3.5.2).
Layer creation options
Layer creation options can be specified in command-line tools using the syntax -lco <NAME>=<VALUE>
or by providing the appropriate arguments to GDALDatasetCreateLayer()
(C) or Dataset.CreateLayer
(Python).
The following layer creation options are supported:
RS=[YES/NO]: whether to start records with the RS=0x1E character, so as to be compatible with the RFC 8142 standard. Defaults to NO, unless the filename extension is "geojsons"
COORDINATE_PRECISION=<integer>: Defaults to
7
. Maximum number of figures after decimal separator to write in coordinates. "Smart" truncation will occur to remove trailing zeros.SIGNIFICANT_FIGURES=<integer>: Defaults to
17
. Maximum number of significant figures when writing floating-point numbers. If explicitly specified, andCOORDINATE_PRECISION
is not, this will also apply to coordinates.ID_FIELD=value: Name of the source field that must be written as the 'id' member of Feature objects.
ID_TYPE=[AUTO/String/Integer]: Type of the 'id' member of Feature objects.
WRITE_NON_FINITE_VALUES=[YES/NO]: (GDAL >= 3.8) Defaults to
NO
. Whether to write NaN / Infinity values. Such values are not allowed in strict JSON mode, but some JSON parsers (libjson-c >= 0.12 for example) can understand them as they are allowed by ECMAScript.AUTODETECT_JSON_STRINGS=[YES/NO]: (GDAL >= 3.8) Defaults to
YES
. Whether to try to interpret string fields as JSON arrays or objects if they start and end with brackets and braces, even if they do not have their subtype set to JSON.WRITE_BBOX=[YES/NO]: (GDAL >= 3.10) Defaults to
NO
. Set to YES to write a bbox property with the bounding box of the geometry at the feature level.
Geometry coordinate precision
Added in version GDAL: 3.9
On creation, the GeoJSONSeq driver supports using the geometry coordinate
precision, from th OGRGeomCoordinatePrecision
settings of the
OGRGeomFieldDefn
. Those settings are used to round the coordinates
of the geometry of the features to an appropriate decimal precision.
Note
The COORDINATE_PRECISION
layer creation option has precedence over
the values set on the OGRGeomFieldDefn
.
The value of those geometry coordinate precision is not serialized in the generated file, hence on reading, the driver will not advertise a geometry coordinate precision.
See Also
RFC 7946 standard: the GeoJSON Format.
RFC 8142 standard: GeoJSON Text Sequences (RS separator)
GeoJSONL: An optimized format for large geographic datasets
JSON streaming on Wikipedia: An overview over formats for concatenated JSON in a single file