# @kartotherian/geojson-mapnikify

> transform geojson with simplestyle-spec into mapnik xml

Latest version **2.1.1** (published 2019-04-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install @kartotherian/geojson-mapnikify
pnpm add @kartotherian/geojson-mapnikify
yarn add @kartotherian/geojson-mapnikify
bun add @kartotherian/geojson-mapnikify
```

Provides the command `geojson-mapnikify`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2019-04-28 |
| First published | 2019-04-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 18.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 41 |
| Author | Tom MacWright |
| Maintainers | catrope, gehel, mateusbs17, mdholloway, mooeypoo, nyurik, pnorman, stephanebisson |
| Keywords | geojson, mapnik, xml, simplestyle |

## Links

- npm: https://www.npmjs.com/package/@kartotherian/geojson-mapnikify
- Repository: https://github.com/mapbox/geojson-mapnikify
- Issues: https://github.com/mapbox/geojson-mapnikify/issues
- npm.io page: https://npm.io/package/@kartotherian/geojson-mapnikify

## Dependencies (9)

- [xtend](https://npm.io/package/xtend.md) ~4.0.0
- [request](https://npm.io/package/request.md) ~2.78.0
- [sigmund](https://npm.io/package/sigmund.md) ~1.0.0
- [minimist](https://npm.io/package/minimist.md) ~1.2.0
- [queue-async](https://npm.io/package/queue-async.md) ~1.0.7
- [agentkeepalive](https://npm.io/package/agentkeepalive.md) ~2.0.2
- [@kartotherian/blend](https://npm.io/package/@kartotherian/blend.md) ^2.0.1
- [@kartotherian/makizushi](https://npm.io/package/@kartotherian/makizushi.md) ^3.0.1
- [@mapbox/geojson-normalize](https://npm.io/package/@mapbox/geojson-normalize.md) ~0.0.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2019-04-28
- 2.1.0 — 2019-04-27

## README

[![Build Status](https://travis-ci.org/mapbox/geojson-mapnikify.svg)](https://travis-ci.org/mapbox/geojson-mapnikify) [![Coverage Status](https://coveralls.io/repos/mapbox/geojson-mapnikify/badge.png)](https://coveralls.io/r/mapbox/geojson-mapnikify) [![Code Climate](https://codeclimate.com/github/mapbox/geojson-mapnikify/badges/gpa.svg)](https://codeclimate.com/github/mapbox/geojson-mapnikify)

# geojson-mapnikify

Transform [GeoJSON](http://geojson.org/) objects into [Mapnik](http://mapnik.org/)
XML stylesheets with embedded GeoJSON data and [simplestyle-spec](https://github.com/mapbox/simplestyle-spec)-derived
styles.

## install

As a dependency:

    npm install --save @kartotherian/geojson-mapnikify

As a binary:

    npm install -g @kartotherian/geojson-mapnikify

## api

Assumptions:

* GeoJSON is valid, and in EPSG:4326
* Styles, if any, are expressed in simplestyle-spec
* Mapnik **3.x** is the rendering engine

## binary

If you install `-g`, you can use `geojson-mapnikify` as a binary that takes
a single GeoJSON file as an argument and writes a Mapnik XML stylesheet
to stdout.

```
$ geojson-mapnikify test/data/point-retina.geojson > stylesheet.xml
$ geojson-mapnikify test/data/point-retina.geojson retina > stylesheet-retina.xml
```

### `mapnikify(geojson, retina, callback)`

Transform GeoJSON into Mapnik XML.

* `geojson` is a GeoJSON object.
* `retina` is true or false for whether the style should be optimized for 2x rendering.
* `callback` called with `(err, xml)` where xml is a string

### url markers

If your GeoJSON object has one or more features with a `marker-url` property, `mapnikify()` will write the images found at the url into a file in a temporary directory and use that path in the Mapnik XML. This uses the [request library](https://www.npmjs.com/package/request) to handle the http file fetching.

By default the request will attempt to fetch binary data from the specified url. If the url is `http` and not `https` , Mapnikify will use [agentkeepalive](https://www.npmjs.com/package/agentkeepalive) to speed up requesting multiple images. There is also a default timeout of 5 seconds.

You can customize the defaults passed to `request()` . Simply set a custom wrapper defined with `request.defaults` . See [request's documentation on defaults](https://www.npmjs.com/package/request#requestdefaultsoptions) for more information. For a quick example, this will set a longer timeout:

```javascript
var mapnikify = require('mapnikify');
var myRequest = require('request').defaults({
  timeout: 10000,
  followRedirect: false
});
mapnikify.setRequestClient(myRequest);

mapnikify(geojson, retina, callback);

mapnikify.setRequestClient(null); // return to mapnikify defaults
```

---
_Source: https://npm.io/package/@kartotherian/geojson-mapnikify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
