{"id":13610656,"url":"https://github.com/mapbox/shp-write","last_synced_at":"2026-01-11T03:49:17.026Z","repository":{"id":10824175,"uuid":"13100780","full_name":"mapbox/shp-write","owner":"mapbox","description":"create and write to shapefiles in pure javascript","archived":false,"fork":false,"pushed_at":"2025-02-18T19:42:26.000Z","size":207,"stargazers_count":304,"open_issues_count":34,"forks_count":192,"subscribers_count":125,"default_branch":"master","last_synced_at":"2025-03-18T13:57:26.634Z","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":"bsd-3-clause","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-09-25T17:42:09.000Z","updated_at":"2025-03-17T08:33:12.000Z","dependencies_parsed_at":"2024-06-19T22:47:14.298Z","dependency_job_id":"b541a400-f3bb-49d5-a2d5-4dba0c332fb4","html_url":"https://github.com/mapbox/shp-write","commit_stats":{"total_commits":113,"total_committers":17,"mean_commits":6.647058823529412,"dds":0.5221238938053097,"last_synced_commit":"48a0fe72c09f74f6256ac8d4177af272d01317c3"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fshp-write","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fshp-write/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fshp-write/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fshp-write/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapbox","download_url":"https://codeload.github.com/mapbox/shp-write/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650554,"owners_count":21139670,"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-08-01T19:01:46.794Z","updated_at":"2026-01-11T03:49:16.954Z","avatar_url":"https://github.com/mapbox.png","language":"JavaScript","readme":"# @mapbox/shp-write\n\nWrites shapefile in pure javascript. Uses [dbf](https://github.com/tmcw/dbf)\nfor the data component, and [jsZIP](http://stuk.github.io/jszip/) to generate downloads in-browser.\n\n\u003e [!IMPORTANT]  \n\u003e **The package location for this repo has changed!**\n\u003e\n\u003e tl;dr: `shp-write` -\u003e [`@mapbox/shp-write`](https://www.npmjs.com/package/@mapbox/shp-write)\n\n\n## Usage\n\nNPM\n\n    npm install --save @mapbox/shp-write\n  \nYarn\n\n    yarn add @mapbox/shp-write\n\nBrowser\n\n    https://unpkg.com/@mapbox/shp-write@latest/shpwrite.js\n\n## Caveats\n\n- Requires a capable fancy modern browser with [Typed Arrays](http://caniuse.com/#feat=typedarrays)\n  support\n- Supports geometries: `Point`, `LineString`, `Polygon`, `MultiLineString`, `MultiPolygon`\n- Tabular-style properties export with [10 character field name length limit](https://en.wikipedia.org/wiki/Shapefile#:~:text=Maximum%20length%20of%20field%20names%20is%2010%20characters) \n- Uses jsZip for ZIP files, but [compression is buggy](https://github.com/Stuk/jszip/issues/53) so it uses STORE instead of DEFLATE.\n\n## Example\n\n```js\nvar shpwrite = require(\"@mapbox/shp-write\");\n\nconst geoJSON = {\n    type: \"FeatureCollection\",\n    features: [\n      {\n        type: \"Feature\",\n        geometry: {\n          type: \"Point\",\n          coordinates: [0, 0],\n        },\n        properties: {\n          name: \"Foo\",\n        },\n      },\n      {\n        type: \"Feature\",\n        geometry: {\n          type: \"Point\",\n          coordinates: [0, 10],\n        },\n        properties: {\n          name: \"Bar\",\n        },\n      },\n    ],\n  };\n\n// Optional custom options passed to the underlying `zip` call \nconst options = {\n  folder: \"my_internal_shapes_folder\",\n  filename: \"my_zip_filename\",\n  outputType: \"blob\",\n  compression: \"DEFLATE\",\n  types: {\n    point: \"mypoints\",\n    polygon: \"mypolygons\",\n    polyline: \"mylines\",\n  },\n};\n\nconst zipData = shpwrite.zip(geoJSON,options);\n```\n\n## Custom .prj file\nTo pass a custom [WKT string](http://www.opengeospatial.org/standards/wkt-crs) in the .prj file to define a different projection the prj option can be used:\n\n```js\nvar options = {\n    prj: 'PROJCS[\"Amersfoort / RD New\",GEOGCS[\"Amersfoort\",DATUM[\"D_Amersfoort\",SPHEROID[\"Bessel_1841\",6377397.155,299.1528128]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295]],PROJECTION[\"Stereographic_North_Pole\"],PARAMETER[\"standard_parallel_1\",52.15616055555555],PARAMETER[\"central_meridian\",5.38763888888889],PARAMETER[\"scale_factor\",0.9999079],PARAMETER[\"false_easting\",155000],PARAMETER[\"false_northing\",463000],UNIT[\"Meter\",1]]'\n}\n```\n\n## API\n\n### `write(data, geometrytype, geometries, callback)`\n\nGenerates a shapefile and calls the callback with err and an object containing shp, shx, and dbf DataViews.\n\n* data: Array of objects for each row of data.\n* geometrytype: The OGC standard geometry type (e.g., POINT).\n* geometries: List of geometries as bare coordinate arrays.\n* callback: Function to handle the generated DataViews.\n  \n```js\nshpwrite.write(data, geometrytype, geometries, (err, result) =\u003e {\n  // result is equal to\n  // {\n  //  shp: DataView(),\n  //  shx: DataView(),\n  //  dbf: DataView()\n  // }\n  if (err) throw err;\n  console.log(result);\n});\n```\n\n### `zip(geojson, [options])`\n\nGenerate a ArrayBuffer of a zipped shapefile, dbf, and prj, from a GeoJSON\nobject.\n\n### `download(geojson, [options])`\n\n\u003e [!WARNING]  \n\u003e This is now marked as deprecated because it applies to browsers only and the\nuser should instead rely on an external library for this functionality like\n`file-saver` or `downloadjs`\n\nGiven a [GeoJSON](http://geojson.org/) FeatureCollection as an object, converts convertible features into Shapefiles and triggers a download. `options` is passed to the underlying `zip` call. \n\n## Other Implementations\n\n- https://code.google.com/p/pyshp/\n\n## Reference\n\n- http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf\n\n## Contributors\n\n- Nick Baugh \u003cniftylettuce@gmail.com\u003e\n- Charles Richardson \u003ccharlesrichardsonusa@gmail.com\u003e\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fshp-write","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapbox%2Fshp-write","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fshp-write/lists"}