FlatGeobuf
FlatGeobuf is a modern binary vector format designed for fast streaming reads. A single self-contained file with UTF-8 text encoding, it avoids the companion-file clutter of Shapefile. Its optional embedded spatial index enables efficient bounding-box queries without reading the whole file, making it well-suited to large datasets served over HTTP. It also works well as a general-purpose GIS exchange format.
File extension: .fgb · Read: ✓ · Write: ✓ · Multi-layer: no (one layer per file)
CLI examples
mapshaper buildings.fgb -info
mapshaper buildings.fgb -simplify 5% -o buildings.geojson
mapshaper provinces.shp -o provinces.fgb
Format-specific input options
There are no FlatGeobuf-specific -i options.
Format-specific output options
There are no FlatGeobuf-specific -o options. The format honors the general flags (precision=, gzip, zip, etc.) where they apply.
Practical notes
- Mapshaper reads CRS metadata from the file header when it's encoded as an EPSG code. WKT2-only definitions can't be parsed and produce an "Unable to import WKT2 CRS from FlatGeobuf" warning — the layer comes in without a CRS.
- On output, Mapshaper embeds an EPSG code in the FlatGeobuf header whenever it can derive one from the source: a round-tripped FlatGeobuf or GeoPackage CRS, an
epsg:NNNNstring passed to-proj, anAUTHORITY["EPSG", N]clause in a Shapefile.prj, or any encoding of WGS-84 or Web Mercator (which covers most GeoJSON, CSV-with-lat/lon and-proj wgs84/-proj webmercatoroutputs). - Mapshaper cannot yet convert an arbitrary proj4 definition (such as a custom Albers projection set with
-proj +proj=aea ...) to an EPSG code. In that case the file is written with no CRS in the header and a warning is printed: "Wrotefoo.fgbwithout a CRS in the FlatGeobuf header...". Re-run the file throughogr2ogrif you need the CRS embedded for downstream tools. - Mapshaper does not write the optional packed R-tree spatial index, and it doesn't use the index for selective reads of indexed input either — the whole file is read into memory. If you need an indexed
.fgbfor HTTP range-request reads, build it withogr2ogror theflatgeobufCLI.
External resources
- flatgeobuf.org — project home with spec links and language bindings.
- Kicking the Tires: FlatGeobuf — an independent practical writeup with benchmarks against Shapefile, GeoJSON and GeoPackage.
- Bryce Mecum: Flatgeobuf — a hands-on exploration of streaming reads in the browser, including a worth-knowing gotcha about the spatial index sitting at the front of the file.
- Cloud-Native Geospatial Formats Guide: FlatGeobuf — how the format fits into modern cloud-storage workflows.
- FlatGeobuf reading and writing in Mapshaper is built on the official
flatgeobufJavaScript library, which provides the FlatBuffers schema, header parsing and feature serialisation primitives.