{"id":13907496,"url":"https://github.com/mapbox/carto","last_synced_at":"2025-07-18T05:32:04.560Z","repository":{"id":1381551,"uuid":"1336005","full_name":"mapbox/carto","owner":"mapbox","description":"fast CSS-like map stylesheets","archived":true,"fork":false,"pushed_at":"2023-10-25T18:54:39.000Z","size":21214,"stargazers_count":656,"open_issues_count":32,"forks_count":129,"subscribers_count":155,"default_branch":"master","last_synced_at":"2024-04-08T01:02:38.231Z","etag":null,"topics":["cartocss","javascript","mapnik","mml"],"latest_commit_sha":null,"homepage":"https://cartocss.readthedocs.io/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mapbox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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}},"created_at":"2011-02-07T00:03:06.000Z","updated_at":"2024-03-05T19:01:31.000Z","dependencies_parsed_at":"2024-01-22T00:15:26.538Z","dependency_job_id":"11841594-5157-4ad3-ac8c-6bd4667a0875","html_url":"https://github.com/mapbox/carto","commit_stats":{"total_commits":1769,"total_committers":60,"mean_commits":"29.483333333333334","dds":0.7320520067834935,"last_synced_commit":"305107201d4f8c4a2b9118c0077dde904f4224ed"},"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fcarto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fcarto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fcarto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mapbox%2Fcarto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mapbox","download_url":"https://codeload.github.com/mapbox/carto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226353714,"owners_count":17611751,"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":["cartocss","javascript","mapnik","mml"],"created_at":"2024-08-06T23:01:57.990Z","updated_at":"2024-11-25T15:32:01.622Z","avatar_url":"https://github.com/mapbox.png","language":"JavaScript","readme":"# CartoCSS\n\n[![Build Status](https://secure.travis-ci.org/mapbox/carto.svg)](http://travis-ci.org/mapbox/carto) [![Build status](https://ci.appveyor.com/api/projects/status/github/mapbox/carto?svg=true)](https://ci.appveyor.com/project/Mapbox/carto) [![Coverage Status](https://coveralls.io/repos/github/mapbox/carto/badge.svg?branch=master)](https://coveralls.io/github/mapbox/carto?branch=master) [![Package Version](https://img.shields.io/npm/v/carto.svg)](https://www.npmjs.com/package/carto) [![Dependencies](https://david-dm.org/mapbox/carto.svg)](https://david-dm.org/mapbox/carto)    [![Documentation Status](https://readthedocs.org/projects/cartocss/badge/?version=latest)](http://cartocss.readthedocs.io/en/latest/?badge=latest)\n\nCartoCSS (short: Carto) is a language for map design. It is similar in syntax to CSS, but builds upon it with specific abilities to filter map data and by providing things like variables.\nIt targets the [Mapnik renderer](http://mapnik.org) and is able to generate Mapnik XML and a JSON variant of Mapnik XML.\nIt can run from the command line or in the browser.\n\nCarto is an evolution of the [Cascadenik](https://github.com/mapnik/Cascadenik) idea and language, with an emphasis on speed and flexibility.\n\n## Documentation\n\nThe best place to start is to review the [CartoCSS documentation](https://cartocss.readthedocs.io).\n\nTutorials like the [Mapbox Getting started with CartoCSS guide](https://github.com/mapbox/mapbox-studio-classic/blob/mb-pages/docs/studio-classic-manual/04-classic-manual-cartocss.md) are a great place to start to learn the basics of CartoCSS.\n\nFor more advanced topics see the [Studio style quickstart guide](https://github.com/mapbox/mapbox-studio-classic/blob/mb-pages/docs/tutorials/style-quickstart.md) and [Studio style manual](https://github.com/mapbox/mapbox-studio-classic/blob/mb-pages/docs/studio-classic-manual/01-classic-manual-intro.md). The links below reference the Tilemill application, which preceded Mapbox Studio Classic, but still contain useful and relevant information.\n\n - [Details on Filtering data with CartoCSS](https://tilemill-project.github.io/tilemill/docs/guides/selectors/)\n - [How order works in rendering](https://tilemill-project.github.io/tilemill/docs/guides/symbol-drawing-order/)\n - [How to style labels](https://tilemill-project.github.io/tilemill/docs/guides/styling-labels/)\n - [How to style lines](https://tilemill-project.github.io/tilemill/docs/guides/styling-lines/)\n - [How to style polygons](https://tilemill-project.github.io/tilemill/docs/guides/styling-polygons/)\n - See also the [Styling Concepts](#styling-concepts) for explanations of advanced features.\n\n## Installation\n\nIf you are using a map design application like Kosmtik, Mapbox Studio Classic or Tilemill you already have CartoCSS installed\nand might be more interested in the language reference.\n\nElse you can install the `carto` binary with NPM by running:\n\n    npm install -g carto\n\nYou should consider using a Node.js version manager like [NVM](https://github.com/creationix/nvm).\nOptionally you may also want to install millstone which is required for resolving data in the same way as Mapbox Studio Classic does:\n\n    npm install -g millstone\n\n\nHaving `millstone` installed specifically enable support for localizing external resources (URLs and local files) referenced in your mml file, and detecting projections (using [node-srs](https://github.com/mapbox/node-srs))\n\n## Usage\n\nNow that Carto is installed you should have a `carto` command line tool available that can be run on a CartoCSS project:\n\n    carto project.mml \u003e mapnik.xml\n\nAvailable parameters:\n* -a / --api VERSION - Specify Mapnik API version (e.g. --api 3.0.10) (default: latest Mapnik API version)\n* -b / --benchmark - Outputs total compile time\n* -f / --file - Outputs to the specified file instead of stdout\n* -h / --help - Display help message\n* -l / --localize - Use millstone to localize resources when loading an MML (default: off)\n* -n / --nosymlink - Use absolute paths instead of symlinking files\n* -o / --output - Specify output format, possible values are `mapnik` and `json` (default: `mapnik`)\n* -ppi RESOLUTION - Pixels per inch used to convert m, mm, cm, in, pt, pc to pixels (default: 90.714)\n* -q / --quiet - Do not output any warnings (default: off)\n* -v / --version - Display version information\n\nAlternatively, Carto can be used from JavaScript.\nThe `Renderer` interface is the main API for developers, and it takes an MML file as a string as input.\n\n```javascript\n// defined variables:\n// - input (the name or identifier of the file being parsed)\nvar carto = require('carto');\n\ntry {\n    var data = fs.readFileSync(input, 'utf-8');\n    var mml = new carto.MML({});\n    mml.load(path.dirname(input), data, function (err, data) {\n        var output = {};\n\n        if (!err) {\n            output = new carto.Renderer({\n                filename: input\n            }).render(data);\n        }\n\n        if (output.msg) {\n            output.msg.forEach(function (v) {\n                if (v.type === 'error') {\n                    console.error(carto.Util.getMessageToPrint(v));\n                }\n                else if (v.type === 'warning') {\n                    console.warn(carto.Util.getMessageToPrint(v));\n                }\n            });\n        }\n\n        // output content (if no errors)\n        if (output.data) {\n            console.log(output.data);\n        }\n    });\n} catch (err) {\n    // program failures\n    ...\n}\n```\n\nIf you want to use CartoCSS within the browser you should not use MML loading via `carto.MML.load`.\nInstead you should supply the JSON of the MML including the Stylesheet strings directly to `carto.Renderer.render`.\n\n## Vim\n\nTo install, download or clone this repository, then copy the `vim-carto`\ndirectory located at `build/vim-carto` to your `~/.vim` directory.\n\n    cp build/vim-carto/* ~/.vim -R\n\n## Credits\n\nCartoCSS is based on [less.js](https://github.com/cloudhead/less.js), a CSS compiler written by Alexis Sellier.\n\nSee also a [list of dependencies](https://david-dm.org/mapbox/carto#info=dependencies\u0026view=list).\n\n## Similar projects\n\n* [Magnacarto](https://github.com/omniscale/magnacarto) (Go implementation of CartoCSS for Mapnik and Mapserver)\n\n## Authors\n\n* Tom MacWright (tmcw)\n* Konstantin Käfer (kkaefer)\n* AJ Ashton (ajashton)\n* Dane Springmeyer (springmeyer)\n* Michael Glanznig (nebulon42)\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fcarto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmapbox%2Fcarto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmapbox%2Fcarto/lists"}