{"id":13426364,"url":"https://github.com/mapbox/geobuf","last_synced_at":"2025-12-15T02:05:00.934Z","repository":{"id":18628490,"uuid":"21834502","full_name":"mapbox/geobuf","owner":"mapbox","description":"A compact binary encoding for geographic data.","archived":false,"fork":false,"pushed_at":"2022-01-17T20:04:08.000Z","size":125,"stargazers_count":951,"open_issues_count":33,"forks_count":84,"subscribers_count":138,"default_branch":"master","last_synced_at":"2024-05-17T02:42:09.808Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapbox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-14T20:27:58.000Z","updated_at":"2024-05-17T01:52:54.000Z","dependencies_parsed_at":"2022-06-26T03:44:30.443Z","dependency_job_id":null,"html_url":"https://github.com/mapbox/geobuf","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fgeobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fgeobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fgeobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fgeobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapbox","download_url":"https://codeload.github.com/mapbox/geobuf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243792343,"owners_count":20348626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T00:01:32.800Z","updated_at":"2025-12-15T02:04:55.899Z","avatar_url":"https://github.com/mapbox.png","language":"JavaScript","readme":"# Geobuf\n\n[![Build Status](https://travis-ci.org/mapbox/geobuf.svg)](https://travis-ci.org/mapbox/geobuf)\n\nGeobuf is a compact binary encoding for geographic data.\n\nGeobuf provides _nearly lossless_ compression of GeoJSON data\ninto [protocol buffers](https://developers.google.com/protocol-buffers/).\nAdvantages over using GeoJSON alone:\n\n- **Very compact**: typically makes GeoJSON 6-8 times smaller.\n- 2-2.5x smaller even when comparing gzipped sizes.\n- **Very fast encoding and decoding** \u0026mdash; even faster than native JSON parse/stringify.\n- Can accommodate any GeoJSON data, including extensions with arbitrary properties.\n\nThe [encoding format](geobuf.proto) also potentially allows:\n\n- Easy **incremental parsing** \u0026mdash; get features out as you read them,\nwithout the need to build in-memory representation of the whole data.\n- **Partial reads** \u0026mdash; read only the parts you actually need, skipping the rest.\n\nThink of this as an attempt to design a simple, modern Shapefile successor\nthat works seamlessly with GeoJSON.\nUnlike [Mapbox Vector Tiles](https://github.com/mapbox/vector-tile-spec/),\nit aims for nearly lossless compression of datasets \u0026mdash; without tiling, projecting coordinates,\nflattening geometries or stripping properties.\n\nNote that the encoding schema is **not stable yet** \u0026mdash;\nit may still change as we get community feedback and discover new ways to improve it.\n\n\"Nearly\" lossless means coordinates are encoded with precision of 6 digits after the decimal point (about 10cm).\n\n\n#### Sample compression sizes\n\nData                | JSON      | JSON (gz) | Geobuf   | Geobuf (gz)\n------------------- | --------: | --------: | -------: | ----------:\nUS zip codes        | 101.85 MB | 26.67 MB  | 12.24 MB | 10.48 MB\nIdaho counties      | 10.92 MB  | 2.57 MB   | 1.37 MB  | 1.17 MB\n\n## API\n\n### encode\n\n```js\nvar buffer = geobuf.encode(geojson, new Pbf());\n```\n\nGiven a GeoJSON object and a [Pbf](https://github.com/mapbox/pbf) object to write to,\nreturns a Geobuf as `UInt8Array` array of bytes.\nIn Node@4.5.0 or later, you can use `Buffer.from` to convert back to a buffer.\n\n### decode\n\n```js\nvar geojson = geobuf.decode(new Pbf(data));\n```\n\nGiven a [Pbf](https://github.com/mapbox/pbf) object with Geobuf data, return a GeoJSON object. When loading Geobuf data over `XMLHttpRequest`, you need to set `responseType` to [`arraybuffer`](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType).\n\n\n## Install\n\nNode and Browserify:\n\n```bash\nnpm install geobuf\n```\n\nBrowser build CDN links:\n\n- https://unpkg.com/geobuf@3.0.2/dist/geobuf.js\n- https://unpkg.com/geobuf@3.0.2/dist/geobuf-dev.js\n\nBuilding locally:\n\n```bash\nnpm install\nnpm run build-dev # dist/geobuf-dev.js (development build)\nnpm run build-min # dist/geobuf.js (minified production build)\n```\n\n\n## Command Line\n\n```bash\nnpm install -g geobuf\n```\n\nInstalls these nifty binaries:\n\n* `geobuf2json`: turn Geobuf from `stdin` or specified file to GeoJSON on `stdout`\n* `json2geobuf`: turn GeoJSON from `stdin` or specified file to Geobuf on `stdout`\n* `shp2geobuf`: given a Shapefile filename, send Geobuf on `stdout`\n\n```bash\njson2geobuf data.json \u003e data.pbf\nshp2geobuf myshapefile \u003e data.pbf\ngeobuf2json data.pbf \u003e data.json\n```\n\nNote that for big files, `geobuf2json` command can be pretty slow, but the bottleneck is not the decoding,\nbut the native `JSON.stringify` on the decoded object to pipe it as a string to `stdout`.\nOn some files, this step may take 40 times more time than actual decoding.\n\n\n## See Also\n\n* [geojsonp](https://github.com/springmeyer/geojsonp) \u0026mdash; the prototype that led to this project\n* [pygeobuf](https://github.com/pygeobuf/pygeobuf) \u0026mdash; Python implementation of Geobuf\n* [twkb](https://github.com/TWKB/Specification) \u0026mdash; a geospatial binary encoding that doesn't support topology\nand doesn't encode any non-geographic properties besides `id`\n* [vector-tile-spec](https://github.com/mapbox/vector-tile-spec)\n* [topojson](https://github.com/mbostock/topojson) \u0026mdash; an extension of GeoJSON that supports topology\n* [WKT and WKB](https://en.wikipedia.org/wiki/Well-known_text) \u0026mdash; popular in databases\n* [EWKB](http://postgis.refractions.net/docs/using_postgis_dbmanagement.html#EWKB_EWKT) \u0026mdash; a popular superset of WKB\n","funding_links":[],"categories":["JavaScript","👨‍💻 JavaScript Libraries","others"],"sub_categories":["Data Processing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fgeobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapbox%2Fgeobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fgeobuf/lists"}