The GeoArrow boundary
Geometry columns stay Arrow columns.
GeoArrow adds geometry layouts and extension metadata to an ordinary Arrow table. The geometry travels with typed attributes instead of taking a separate application path.
Geospatial inputs
GeoArrow table
geometry · attributes · CRS metadata
GeoArrow is a convention on top of Arrow, so the result stays compatible with Arrow IPC and the broader Arrow ecosystem.
One loader, several useful shapes
Use objects for clarity and columns for throughput.
Choose the output that matches the next stage of the application. The source document stays GeoJSON; the returned representation can be convenient objects or typed binary columns.
Features
GeoJSON table for mapping and inspection
Binary
Compact geometry buffers
Arrow
Typed columns with WKB geometry
Batches
Incremental results for NDJSON and large inputs
Streaming loader for GeoJSON encoded files.
Detailed guide
GeoJSON usage and output shapes
The sections below cover simple loading, alternate shapes, streaming, reprojection, and loader options.
GeoJSON is a geospatial interchange format that uses JSON encoding. Use GeoJSONLoader for GeoJSON semantics such as features, geometries, feature collections, and GeoArrow WKB output; use JSONLoader for arbitrary JSON documents.
| GeoJSONLoader | |
|---|---|
| File Extension | .geojson |
| Media Type | application/geo+json |
| File Type | Text |
| File Format | GeoJSON |
| Data Format | GeoArrow Arrow table |
| Supported APIs | load, parse, parseSync, parseInBatches |
Usage
For simple usage, load a GeoJSON FeatureCollection as a loaders.gl Arrow table:
import {GeoJSONLoader} from '@loaders.gl/tables/geojson';
import {load} from '@loaders.gl/core';
const data = await load(url, GeoJSONLoader);
Use geojson.shape to request a different output shape.
const binary = await load(url, GeoJSONLoader, {
geojson: {shape: 'binary-feature-collection'}
});
const arrowTable = await load(url, GeoJSONLoader, {
geojson: {shape: 'arrow'}
});
GeoJSONLoader defaults to geojson.shape: 'arrow', converting features to a GeoArrow-compatible Arrow table. Set geojson.shape: 'geojson-table' when an object-row GeoJSONTable is required for compatibility. Feature properties become regular columns and the geometry is written to a binary geometry column with geoarrow.wkb metadata by default. Set geoarrow.encodingPreference to 'optimized' for native coordinate buffers or to 'geoarrow.geometry' for a stable dense union. Use json.geoarrowGeometryColumn to choose a different geometry column name.
const nativeTable = await load(url, GeoJSONLoader, {
geojson: {shape: 'arrow'},
geoarrow: {encodingPreference: 'optimized'}
});
For larger files, GeoJSONLoader supports streaming JSON parsing, in which case it yields batches of rows from one array. By default, streamed GeoJSON reads $.features. You can override options.json.jsonpaths when the feature array is stored elsewhere.
import {GeoJSONLoader} from '@loaders.gl/tables/geojson';
import {loadInBatches} from '@loaders.gl/core';
const batches = await loadInBatches('geojson.json', GeoJSONLoader, {
geojson: {shape: 'geojson-table'}
});
for await (const batch of batches) {
// batch.data will contain a number of rows
for (const feature of batch.data) {
switch (feature.geometry.type) {
case 'Polygon':
...
}
}
}
With geojson.shape: 'geojson-table', when batch parsing an embedded JSON array, it is possible to get access to the containing object by setting core.metadata: true.
The loader will yield an initial and a final batch with batch.container providing the container object and batch.batchType set to partial-result and final-result respectively.
import {GeoJSONLoader} from '@loaders.gl/tables/geojson';
import {loadInBatches} from '@loaders.gl/core';
const batches = await loadInBatches('geojson.json', GeoJSONLoader, {
geojson: {shape: 'geojson-table'},
core: {metadata: true}
});
for await (const batch of batches) {
switch (batch.batchType) {
case 'partial-result': // contains fields seen so far
case 'final-result': // contains all fields except the streamed array
console.log(batch.container);
break;
case 'data':
// batch.data will contain a number of rows
for (const feature of batch.data) {
switch (feature.geometry.type) {
case 'Polygon':
...
}
}
}
}
Data Format
Arrow output consists of native RecordBatch objects. Schema metadata snapshots accumulate container properties under loaders.gl.containerJson and GeoArrow CRS information. A final zero-row batch carries trailing refinements. Empty inputs retain their declared schema. Batch-local paths use batch.metadata.get('jsonpath').
Explicit row-output batches use the following format
{
batchType: 'metadata' | 'partial-result' | 'final-result' | undefined;
jsonpath: string;
// standard batch payload
data: any[] | any;
bytesUsed: number;
batchCount: number;
}
Options
Supports table category options such as batchType and batchSize.
| Option | From | Type | Default | Description |
|---|---|---|---|---|
geojson.shape | string | 'arrow' | Requested output shape. Supported values are 'arrow', 'geojson-table', and 'binary-feature-collection'. | |
json.schema | Schema | arrow.Schema | undefined | Optional full output schema used when geojson.shape is 'arrow'. The schema must include the geometry column. | |
json.arrowConversion | object | {onTypeMismatch: 'error', onMissingField: 'error', onExtraField: 'error', integerConversion: 'error', logRecoveries: true} | Optional Arrow conversion policy for geojson.shape: 'arrow'. onTypeMismatch: 'null', onMissingField: 'null', and integerConversion: 'null' write null only for nullable fields. onExtraField: 'drop' omits fields that are not in the schema. integerConversion: 'clamp-and-round' applies lossy integer conversion, and 'warn' does the same while logging. | |
json.arrowConversion.viewTypes | 'never' | 'prefer' | 'require' | 'never' | Controls whether supported Arrow runtimes emit BinaryView and Utf8View, with fallback in 'prefer' mode. | |
json.geoarrowGeometryColumn | string | 'geometry' | Geometry column name used for GeoArrow WKB output. Requires geojson.shape: 'arrow'. | |
geoarrow.encodingPreference | 'geoarrow.wkb' | 'geoarrow.geometry' | 'optimized' | 'geoarrow.wkb' | Arrow geometry representation. WKB is compact and compatible; geoarrow.geometry is a stable dense union; optimized selects a concrete native encoding for homogeneous data and a dense union for mixed data. | |
json.jsonpaths | [ | string[] | ['$.features'] | A list of JSON paths (see below) indicating the array that can be streamed. |
core.metadata | [ | boolean | false | For explicit row output, if true, yields an initial and final batch containing the partial and final result (i.e. the root object, excluding the array being streamed). |
JSONPaths
The loader implements a focused subset of the IETF JSONPath specification (RFC 9535). See the JSONPath support table for the full list of supported and unsupported features.
JSONPaths are used only to identify which array should be streamed, so selectors such as $.features[*] and $.features[:] are normalized to $.features. Descendant operators, element indexes, filters, and unions are not supported. Regardless of the paths provided, only arrays will be streamed.
Attribution
This loader is based on a fork of dscape's clarinet under BSD 2-clause license.