{"id":13784328,"url":"https://github.com/mapnik/node-mapnik","last_synced_at":"2025-05-14T08:09:45.993Z","repository":{"id":1183662,"uuid":"1084114","full_name":"mapnik/node-mapnik","owner":"mapnik","description":"Bindings to mapnik for node.js","archived":false,"fork":false,"pushed_at":"2025-04-08T08:14:47.000Z","size":22052,"stargazers_count":539,"open_issues_count":104,"forks_count":166,"subscribers_count":31,"default_branch":"master","last_synced_at":"2025-05-13T05:47:33.706Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://mapnik.org/documentation/node-mapnik","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"larowlan/pathauto","license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapnik.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2010-11-16T04:00:45.000Z","updated_at":"2025-05-08T03:16:16.000Z","dependencies_parsed_at":"2024-06-03T10:32:12.289Z","dependency_job_id":"591bce25-378e-4b3f-95ba-6c29fa4c8f64","html_url":"https://github.com/mapnik/node-mapnik","commit_stats":{"total_commits":3317,"total_committers":53,"mean_commits":62.58490566037736,"dds":0.6557129936689781,"last_synced_commit":"650c937c12c31c0571f07878a90f847ba001d00d"},"previous_names":[],"tags_count":193,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapnik%2Fnode-mapnik","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapnik%2Fnode-mapnik/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapnik%2Fnode-mapnik/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapnik%2Fnode-mapnik/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapnik","download_url":"https://codeload.github.com/mapnik/node-mapnik/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101559,"owners_count":22014908,"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-03T19:00:40.151Z","updated_at":"2025-05-14T08:09:40.985Z","avatar_url":"https://github.com/mapnik.png","language":"C++","funding_links":[],"categories":["Uncategorized","Parsers \u0026 Generators","Libraries"],"sub_categories":["Uncategorized","JavaScript"],"readme":"# node-mapnik\n\nBindings to [Mapnik](http://mapnik.org) for [node](http://nodejs.org).\n\n## Usage\n\nRender a map from a stylesheet:\n\n```js\nconst fs = require('node:fs');\nconst mapnik = require('@mapnik/mapnik');\n\n// register fonts and datasource plugins\nmapnik.register_default_fonts();\nmapnik.register_default_input_plugins();\n\nvar map = new mapnik.Map(256, 256);\nmap.load('./test/stylesheet.xml', function(err,map) {\n    if (err) throw err;\n    map.zoomAll();\n    var im = new mapnik.Image(256, 256);\n    map.render(im, function(err,im) {\n      if (err) throw err;\n      im.encode('png', function(err,buffer) {\n          if (err) throw err;\n          fs.writeFile('map.png',buffer, function(err) {\n              if (err) throw err;\n              console.log('saved map image to map.png');\n          });\n      });\n    });\n});\n```\n\nConvert a jpeg image to a png:\n\n```js\nvar mapnik = require('@mapnik/mapnik');\nnew mapnik.Image.open('input.jpg').save('output.png');\n```\n\nConvert a shapefile to GeoJSON:\n\n```js\nconst fs = require('node:fs');\nconst path = require('node:path');\nconst mapnik = require('@mapnik/mapnik');\n\nmapnik.register_datasource(path.join(mapnik.settings.paths.input_plugins,'shape.input'));\nvar ds = new mapnik.Datasource({type:'shape',file:'test/data/world_merc.shp'});\nvar featureset = ds.featureset()\nvar geojson = {\n  \"type\": \"FeatureCollection\",\n  \"features\": [\n  ]\n}\nvar feat = featureset.next();\nwhile (feat) {\n    geojson.features.push(JSON.parse(feat.toJSON()));\n    feat = featureset.next();\n}\nfs.writeFileSync(\"output.geojson\",JSON.stringify(geojson,null,2));\n```\n\nFor more sample code see [the tests](./test) and [sample code](https://github.com/mapnik/node-mapnik-sample-code).\n\n## Requirements\n\nStarting from `v4.6.0`, `node-mapnik` module is published as \"universal\" binaries on [GitHub NPM registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry) and [npmjs](https://www.npmjs.com) using [node-addon-api](https://github.com/nodejs/node-addon-api),\n[node-gyp-build](https://github.com/prebuild/node-gyp-build) and [prebuildify](https://github.com/prebuild/prebuildify)\n\nCurrently supported platforms are\n\n* `linux-x64`\n* `linux-arm64` (from v4.6.5)\n* `darwin-x64`\n* `darwin-arm64`\n\n\nConsult N-API documentation for more details: https://nodejs.org/dist/latest/docs/api/n-api.html#n_api_node_api_version_matrix\n\n\n## Installing\n\n### With npm\n\n```bash\nnpm install @mapnik/mapnik\n```\nNote: If using GitHub NPM registry consult \"[Installing a package](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#installing-a-package)\n\". You will need to authenticate to GitHub Packages, see \"[Authenticating to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages).\"\n\n* Check for config file [`.npmrc`](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc), create a new .npmrc file if one doesn't exist.\n* Edit the .npmrc file to include the following lines, replacing TOKEN with your personal access token.\n```bash\n@mapnik:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=XXXXXXXXXXXXXXXXXXXXXXXXX\n```\nNote: This will install the latest node-mapnik 4.6.x series, which is recommended.\n\n\n\n### Source Build [WIP]\n\nOn macOS and Linux:\n\n* Ensure `mapnik-config` program is available and on your `${PATH}`.\n\n* `npm install --build-from-source`\n\n* To \"prebuild\" binaries `npm run prebuildify`\n\n#### Note on SSE:\n\nSSE support is enabled by default on `x86_64`.\n\n## Using node-mapnik from your node app\n\nTo require node-mapnik as a dependency of another package put in your package.json:\n\n    \"dependencies\"  : { \"@mapnik/mapnik\":\"*\" } // replace * with a given semver version string\n\n## Tests\n\nTo run the tests do:\n\n    npm test\n\n## License\n\nBSD, see LICENSE.txt\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapnik%2Fnode-mapnik","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapnik%2Fnode-mapnik","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapnik%2Fnode-mapnik/lists"}