{"id":13426302,"url":"https://github.com/calvinmetcalf/shapefile-js","last_synced_at":"2025-05-14T14:09:56.179Z","repository":{"id":3431654,"uuid":"4483646","full_name":"calvinmetcalf/shapefile-js","owner":"calvinmetcalf","description":"Convert a Shapefile to GeoJSON. Not many caveats.","archived":false,"fork":false,"pushed_at":"2024-10-02T19:01:45.000Z","size":47900,"stargazers_count":764,"open_issues_count":21,"forks_count":237,"subscribers_count":22,"default_branch":"gh-pages","last_synced_at":"2025-05-04T23:04:32.641Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"http://calvinmetcalf.github.io/shapefile-js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/calvinmetcalf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2012-05-29T15:11:14.000Z","updated_at":"2025-04-17T02:15:20.000Z","dependencies_parsed_at":"2024-01-16T18:59:58.194Z","dependency_job_id":"6ff998e9-9923-45d0-864f-0e3d44af8ad7","html_url":"https://github.com/calvinmetcalf/shapefile-js","commit_stats":{"total_commits":297,"total_committers":22,"mean_commits":13.5,"dds":0.5892255892255892,"last_synced_commit":"b23b6ea5f97206361779037554010913a4ea5c7e"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calvinmetcalf%2Fshapefile-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calvinmetcalf%2Fshapefile-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calvinmetcalf%2Fshapefile-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calvinmetcalf%2Fshapefile-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calvinmetcalf","download_url":"https://codeload.github.com/calvinmetcalf/shapefile-js/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160546,"owners_count":22024571,"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":["hacktoberfest"],"created_at":"2024-07-31T00:01:31.341Z","updated_at":"2025-05-14T14:09:51.170Z","avatar_url":"https://github.com/calvinmetcalf.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Shapefile.js\n\nPure JavaScript library for parsing Shapefiles, returns Geojson projected into WGS84 lat lons.\n\n## Usage\n\nFor use in node, rollup, webpack and where ever ESM modules are used we have a lovely package you can install via npm or yarn or whatever.\n\n    npm install shpjs --save\n\nIf you need a stand alone file to include in your webpage the old fashioned way then you can grab the built version that's either included in the repo or you can use unpkg.\n\n    https://unpkg.com/shpjs@latest/dist/shp.js\n\nor\n\n\thttps://unpkg.com/shpjs@latest/dist/shp.min.js\n\n\nWhen using this library in some sort of bundler for the browser, no polyfills for node apis are required, the only thing needed is some sort of dependency resolver plugin like [rollup node-resolve](https://www.npmjs.com/package/@rollup/plugin-node-resolve) if your bundler doesn't have it, you are almost certainly already using one to get this library anyway.\n\nAddtionally you can import it directly into an esm based web script with \n\n```js\nimport shp from 'https://unpkg.com/shpjs@latest/dist/shp.esm.js'\n```\n\n## API\n\nThere are 3 ways to use it:\n\n1\\. you can pass it a url to a shapefile, either to the shapefile itself (with or without the .shp suffix)\n\n```javascript\n\timport shp from 'shpjs';\n\t//for the shapefiles in the folder called 'files' with the name pandr.shp\n\tconst geojson = await shp(\"files/pandr.shp\");\n```\n\nor you can pass it a url to a a .zip file which contains the shapefile\n\n```javascript\n\t//for the shapefiles in the files folder called pandr.shp\n\tconst geojson = await shp(\"files/pandr.zip\");\n```\n\n2\\. you can pass in in a binary buffer (ArrayBuffer, TypedArray, DataView, Node Buffer) containing a zip file containing at least one shapefile like from a file in node:\n\n```javascript\n// in node\nconst data = await fs.readFile('./path/to/shp.zip');\nconst geojson = await shp(data);\n```\nor the [File API](https://developer.mozilla.org/en-US/docs/Web/API/File) in the browser\n\n```javascript\n// in browser from some sort of file upload\nconst data = await file.arrayBuffer()\nconst geojson = await shp(data);\n```\n\n3\\. You can pass in an object with `shp`, `dbf`, `prj`, and `cpg` properties.\n\n```javascript\nconst object = {}\nobject.shp = await fs.readFile('./path/to/file.shp');\n// dbf is optional, but needed if you want attributes\nobject.dbf = await fs.readFile('./path/to/file.dbf');\n// prj is optional, but needed if your file is in some projection you don't want it in\nobject.prj = await fs.readFile('./path/to/file.prj');\n// cpg is optional but needed if your dbf is in some weird (non utf8) encoding.\nobject.cpg = await fs.readFile('./path/to/file.cpg');\n\nconst geojson = await shp(object)\n```\n\n## on zipfiles\n\nIf there is only one shp in the zipefile it returns geojson, if there are multiple then it will be an array.  All of the geojson objects have an extra key `fileName` the value of which is the\nname of the shapefile minus the extension (I.E. the part of the name that's the same for all of them).\n\n\n# links\n\n- [wikipedia article](https://en.wikipedia.org/wiki/Shapefile)\n- [ESRI white paper](http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf)\n- [This page on Xbase](http://www.clicketyclick.dk/databases/xbase/format/dbf.html)\n\n## Demos\n\n- [Countries/zipfile](http://calvinmetcalf.github.io/shapefile-js)\n- [Google maps](http://calvinmetcalf.github.io/shapefile-js/site/map.html)\n- [Local Zipfile](http://leaflet.calvinmetcalf.com)\n- [Projected big with web workers](http://calvinmetcalf.github.io/shapefile-js/site/proj.html)\n\n## About\n\nDescended in a ship of theseus way from [RandomEtc's shapefile library](https://github.com/RandomEtc/shapefile-js) no code is shared.\n\n- [World Borders shapefile](http://thematicmapping.org/downloads/world_borders.php) is CC-BY-SA 3.0.\n- Park and Ride shapefile is from [MassDOT](http://mass.gov/massdot) and is public domain.\n- MA town boundaries from [MassGIS](http://www.mass.gov/anf/research-and-tech/it-serv-and-support/application-serv/office-of-geographic-information-massgis/) and is public domain\n- NJ County Boundaries from [NJgin](https://njgin.state.nj.us/NJ_NJGINExplorer/index.jsp) and should be public domain.\n- [Proj4js](https://github.com/proj4js/proj4js) by me et al MIT\n- Other test datasets copyright their respective owners.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalvinmetcalf%2Fshapefile-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalvinmetcalf%2Fshapefile-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalvinmetcalf%2Fshapefile-js/lists"}