Mapnik | Documentation

### Mapnik

``

## mapnik

`src/node_mapnik.cpp`

Mapnik is the core of cartographic design and processing.

#### Properties

- `string` version :

  current version of mapnik

- `string` module_path :

  path to native mapnik binding

- `Object` supports :

  indicates which of the following are supported: grid, svg, cairo, cairo_pdf, cairo_svg, png, jpeg, tiff, webp, proj4, threadsafe

- `Object` versions :

  diagnostic object with versions of node, v8, boost, boost_number, mapnik, mapnik_number, mapnik_git_describe, cairo

#### Examples

    var mapnik = require('node-mapnik');

#### Static members

`.compositeOp`

Image type constants representing color and grayscale encodings. Composite operation constants

## compositeOp

`src/node_mapnik.cpp`

Image type constants representing color and grayscale encodings. Composite operation constants

#### Properties

- `number` clear
- `number` src
- `number` dst
- `number` src_over
- `number` dst_over
- `number` src_in
- `number` dst_in
- `number` src_out
- `number` dst_out
- `number` src_atop
- `number` dst_atop
- `number` xor
- `number` plus
- `number` minus
- `number` multiply
- `number` screen
- `number` overlay
- `number` darken
- `number` lighten
- `number` color_dodge
- `number` color_burn
- `number` hard_light
- `number` soft_light
- `number` difference
- `number` exclusion
- `number` contrast
- `number` invert
- `number` invert :

  -rgb

- `number` grain_merge
- `number` grain_extract
- `number` hue
- `number` saturation
- `number` color
- `number` linear_dodge
- `number` linear_burn
- `number` divide

`.imageScaling`

Image scaling type constants representing color and grayscale encodings.

## imageScaling

`src/node_mapnik.cpp`

Image scaling type constants representing color and grayscale encodings.

#### Properties

- `number` near
- `number` bilinear
- `number` bicubic
- `number` spline16
- `number` spline36
- `number` hanning
- `number` hamming
- `number` hermite
- `number` kaiser
- `number` quadric
- `number` catrom
- `number` gaussian
- `number` bessel
- `number` mitchell
- `number` sinc
- `number` lanczos
- `number` blackman

`.imageType`

Image type constants representing color and grayscale encodings.

## imageType

`src/node_mapnik.cpp`

Image type constants representing color and grayscale encodings.

#### Properties

- `number` rgba8
- `number` gray8
- `number` gray8s
- `number` gray16
- `number` gray16s
- `number` gray32
- `number` gray32s
- `number` gray32f
- `number` gray64
- `number` gray64s
- `number` gray64f

`.polygonFillType`

Image scaling type constants representing color and grayscale encodings.

## polygonFillType

`src/node_mapnik.cpp`

Image scaling type constants representing color and grayscale encodings.

#### Properties

- `number` evenOdd
- `number` nonZero
- `number` positive
- `number` negative

## mapnik.Color(value, green, blue, blue, premultiplied)

`src/mapnik_color.cpp`

#### Parameters

- `string` or `number` value :

  either an array of [r, g, b, a], a color keyword, or a CSS color in rgba() form.

- `number` green :
- `number` blue :
- `number` blue :
- `boolean` premultiplied :

#### Throws

- `TypeError`:

  if a rgb component is outside of the 0-255 range

#### Examples

    var c = new mapnik.Color('green');
    var c = new mapnik.Color(0, 128, 0, 255);
    // premultiplied
    var c = new mapnik.Color(0, 128, 0, 255, true);

#### Instance members

`#get_premultiplied`

Get whether this color is premultiplied

## get_premultiplied

`src/mapnik_color.cpp`

Get whether this color is premultiplied

#### Returns

``boolean`` :

premultiplied

`#hex`

Get this color represented as a hexademical string

## hex

`src/mapnik_color.cpp`

Get this color represented as a hexademical string

#### Returns

``string`` :

hex representation

#### Examples

    var c = new mapnik.Color('green');
                c.hex();
                // '#008000'

`#set_premultiplied(premultiplied)`

Set whether this color should be premultiplied

## set_premultiplied(premultiplied)

`src/mapnik_color.cpp`

Set whether this color should be premultiplied

#### Parameters

- `boolean` premultiplied :

#### Throws

- `TypeError`:

  given a non-boolean argument

#### Examples

    var c = new mapnik.Color('green');
                c.set_premultiplied(true);

`#toString`

Get this color's representation as a string

## toString

`src/mapnik_color.cpp`

Get this color's representation as a string

#### Returns

``string`` :

color as a string

#### Examples

    var green = new mapnik.Color('green');
                green.toString()
                // 'rgb(0,128,0)'

## mapnik.Datasource

`src/mapnik_datasource.cpp`

A Datasource object. This is the connector from Mapnik to any kind of file, network, or database source of geographical data.

#### Instance members

`#describe`

Describe the datasource's contents and type.

## describe

`src/mapnik_datasource.cpp`

Describe the datasource's contents and type.

#### Returns

``Object`` :

description: an object with type, fields, encoding, geometry_type, and proj4 code

`#extent`

Get the Datasource's extent

## extent

`src/mapnik_datasource.cpp`

Get the Datasource's extent

## mapnik.Feature

`src/mapnik_feature.cpp`

A single geographic feature, with geometry and properties. This is typically derived from data by a datasource, but can be manually created.

#### Static members

`.fromJSON(geojson)`

## fromJSON(geojson)

`src/mapnik_feature.cpp`

#### Parameters

- `string` geojson :

  string

  Create a feature from a GeoJSON representation.

#### Instance members

`#attributes`

Get the feature's attributes as an object.

## attributes

`src/mapnik_feature.cpp`

Get the feature's attributes as an object.

#### Returns

``Object`` :

attributes

`#extent`

Get the feature's extent

## extent

`src/mapnik_feature.cpp`

Get the feature's extent

`#geometry`

Get the feature's attributes as a Mapnik geometry.

## geometry

`src/mapnik_feature.cpp`

Get the feature's attributes as a Mapnik geometry.

#### Returns

``mapnik.Geometry`` :

geometry

`#id`

## id

`src/mapnik_feature.cpp`

#### Returns

``number`` :

id the feature's internal id

`#toJSON`

Generate and return a GeoJSON representation of this feature

## toJSON

`src/mapnik_feature.cpp`

Generate and return a GeoJSON representation of this feature

#### Returns

``string`` :

geojson Feature object in stringified GeoJSON

## mapnik.Featureset

`src/mapnik_featureset.cpp`

An iterator of `mapnik.Feature` objects.

#### Instance members

`#next`

Return the next Feature in this featureset if it exists, or `null` if it does not.

## next

`src/mapnik_featureset.cpp`

Return the next Feature in this featureset if it exists, or `null` if it does not.

#### Returns

``mapnik.Feature` or` :

next feature

## mapnik.Geometry

`src/mapnik_geometry.cpp`

Geometry: a representation of geographical features in terms of shape alone. This class provides many useful functions for conversion to and from formats.

You'll never create a mapnik.Geometry instance manually: it is always part of a `mapnik.Feature` instance, which is often a part of a `mapnik.Featureset` instance.

#### Instance members

`#extent`

Get the geometry's extent

## extent

`src/mapnik_geometry.cpp`

Get the geometry's extent

`#toJSON([options], callback)`

Convert this geometry into a GeoJSON representation, asynchronously.

## toJSON([options], callback)

`src/mapnik_geometry.cpp`

Convert this geometry into a GeoJSON representation, asynchronously.

#### Parameters

- `[`Object`]` options (default `{}`) :

  . The only supported object is `transform`, which should be a valid `mapnik.ProjTransform` object.

- `Function` callback :

  called with (err, result)

`#toJSONSync`

Convert this geometry into a GeoJSON representation, synchronously.

## toJSONSync

`src/mapnik_geometry.cpp`

Convert this geometry into a GeoJSON representation, synchronously.

#### Returns

``string`` :

GeoJSON, string-encoded representation of this geometry.

`#toWKB`

Get the geometry's representation as Well-Known Binary

## toWKB

`src/mapnik_geometry.cpp`

Get the geometry's representation as Well-Known Binary

#### Returns

``string`` :

wkb representation of this geometry

`#toWKT`

Get the geometry's representation as Well-Known Text

## toWKT

`src/mapnik_geometry.cpp`

Get the geometry's representation as Well-Known Text

#### Returns

``string`` :

wkt representation of this geometry

## mapnik.Grid(width, height, [options])

`src/mapnik_grid.cpp`

Generator for UTFGrid representations of data.

#### Parameters

- `number` width :
- `number` height :
- `[`Object`]` options (default `{}`) :

  optional argument, which can have a 'key' property

#### Properties

- `string` key

#### Instance members

`#addField`

Get all of this grid's fields

## addField

`src/mapnik_grid.cpp`

Get all of this grid's fields

`#addField(field)`

Add a field to this grid's output

## addField(field)

`src/mapnik_grid.cpp`

Add a field to this grid's output

#### Parameters

- `string` field :

`#encodeSync([options])`

Get a constrained view of this field given x, y, width, height parameters.

## encodeSync([options])

`src/mapnik_grid.cpp`

Get a constrained view of this field given x, y, width, height parameters.

#### Parameters

- `[`Object`]` options (default `{ resolution: 4, features: false }`) :

#### Returns

``Object`` :

an encoded field with `grid`, `keys`, and `data` members.

`#height`

Get this grid's height

## height

`src/mapnik_grid.cpp`

Get this grid's height

#### Returns

``number`` :

height

`#view(x, y, width, height)`

Get a constrained view of this field given x, y, width, height parameters.

## view(x, y, width, height)

`src/mapnik_grid.cpp`

Get a constrained view of this field given x, y, width, height parameters.

#### Parameters

- `number` x :
- `number` y :
- `number` width :
- `number` height :

#### Returns

``mapnik.Grid`` :

a grid constrained to this new view

`#width`

Get this grid's width

## width

`src/mapnik_grid.cpp`

Get this grid's width

#### Returns

``number`` :

width

## mapnik.Image(width, height, options)

`src/mapnik_image.cpp`

#### Parameters

- `number` width :
- `number` height :
- `Object` options :

  valid options are `premultiplied`, `painted`, `type` and `initialize`.

#### Throws

- `TypeError`:

  if any argument is the wrong type, like if width or height is not numeric.

#### Examples

    var im = new mapnik.Image(256, 256, {
      premultiplied: true,
      type: mapnik.imageType.gray8
    });

#### Static members

`.fromBufferSync(width, height, buffer)`

Create an image of the existing buffer. BUFFER MUST LIVE AS LONG AS THE IMAGE. It is recommended that you do not use this method! Be warned!

## fromBufferSync(width, height, buffer)

`src/mapnik_image.cpp`

Create an image of the existing buffer. BUFFER MUST LIVE AS LONG AS THE IMAGE. It is recommended that you do not use this method! Be warned!

#### Parameters

- `number` width :
- `number` height :
- `Buffer` buffer :

#### Returns

``mapnik.Image`` :

image object

`.fromBytes(buffer, callback)`

Create a new image from a buffer

## fromBytes(buffer, callback)

`src/mapnik_image.cpp`

Create a new image from a buffer

#### Parameters

- `Buffer` buffer :
- `Function` callback :

`.fromSVG(filename, callback)`

Create a new image from an SVG file

## fromSVG(filename, callback)

`src/mapnik_image.cpp`

Create a new image from an SVG file

#### Parameters

- `String` filename :
- `Function` callback :

`.fromSVGBytes(filename, callback)`

Create a new image from an SVG file

## fromSVGBytes(filename, callback)

`src/mapnik_image.cpp`

Create a new image from an SVG file

#### Parameters

- `String` filename :
- `Function` callback :

#### Instance members

`#clear(callback)`

Make this image transparent, removing all image data from it.

## clear(callback)

`src/mapnik_image.cpp`

Make this image transparent, removing all image data from it.

#### Parameters

- `Function` callback :

`#clearSync`

Make this image transparent.

## clearSync

`src/mapnik_image.cpp`

Make this image transparent.

#### Examples

    var im = new mapnik.Image(5,5);
                im.fillSync(1);
                assert.equal(im.getPixel(0, 0), 1);
                im.clearSync();
                assert.equal(im.getPixel(0, 0), 0);

`#compare(other, [options])`

Compare two images visually. This is useful for algorithms and tests that confirm whether a certain image has changed significantly.

## compare(other, [options])

`src/mapnik_image.cpp`

Compare two images visually. This is useful for algorithms and tests that confirm whether a certain image has changed significantly.

#### Parameters

- `mapnik.Image` other :

  another image instance

- `[`Object`]` options (default `{threshold:16,alpha:true}`) :

#### Returns

``number`` :

quantified visual difference between these two images

`#composite(other, callback)`

Overlay this image with another image, creating a layered composite as a new image

## composite(other, callback)

`src/mapnik_image.cpp`

Overlay this image with another image, creating a layered composite as a new image

#### Parameters

- `mapnik.Image` other :
- `Function` callback :

`#copy(type, [options], callback)`

Copy this image data so that changes can be made to a clone of it.

## copy(type, [options], callback)

`src/mapnik_image.cpp`

Copy this image data so that changes can be made to a clone of it.

#### Parameters

- `number` type :
- `[`Object`]` options (default `{}`) :
- `Function` callback :

`#copySync(type, [options])`

Copy this image data so that changes can be made to a clone of it.

## copySync(type, [options])

`src/mapnik_image.cpp`

Copy this image data so that changes can be made to a clone of it.

#### Parameters

- `number` type :
- `[`Object`]` options (default `{}`) :

#### Returns

``mapnik.Image`` :

copy

`#demultiply(callback)`

Demultiply the pixels in this image, asynchronously. The opposite of premultiplying

## demultiply(callback)

`src/mapnik_image.cpp`

Demultiply the pixels in this image, asynchronously. The opposite of premultiplying

#### Parameters

- `Function` callback :

`#demultiplySync`

Demultiply the pixels in this image. The opposite of premultiplying

## demultiplySync

`src/mapnik_image.cpp`

Demultiply the pixels in this image. The opposite of premultiplying

`#encode([format], callback)`

Encode this image into a buffer of encoded data

## encode([format], callback)

`src/mapnik_image.cpp`

Encode this image into a buffer of encoded data

#### Parameters

- `[`string`]` format (default `png`) :

  image format

- `Function` callback :

#### Returns

``Buffer`` :

encoded image data

#### Examples

    var fs = require('fs');
                myImage.encode('png', function(err, encoded) {
                  fs.writeFileSync('myimage.png', encoded);
                });

`#encodeSync([format])`

Encode this image into a buffer of encoded data

## encodeSync([format])

`src/mapnik_image.cpp`

Encode this image into a buffer of encoded data

#### Parameters

- `[`string`]` format (default `png`) :

  image format

#### Returns

``Buffer`` :

encoded image data

#### Examples

    var fs = require('fs');
                fs.writeFileSync('myimage.png', myImage.encodeSync('png'));

`#fill(color, callback)`

Asynchronously fill this image with a given color.

## fill(color, callback)

`src/mapnik_image.cpp`

Asynchronously fill this image with a given color.

#### Parameters

- `mapnik.Color` or `number` color :
- `Function` callback :

#### Examples

    var im = new mapnik.Image(5, 5);
                im.fill(1, function(err, im_res) {
                  if (err) throw err;
                  assert.equal(im_res.getPixel(0, 0), 1);
                });

`#fillSync(color)`

Fill this image with a given color

## fillSync(color)

`src/mapnik_image.cpp`

Fill this image with a given color

#### Parameters

- `mapnik.Color` or `number` color :

`#filter(filter, callback)`

Asynchronously filter this image.

## filter(filter, callback)

`src/mapnik_image.cpp`

Asynchronously filter this image.

#### Parameters

- `string` filter :
- `Function` callback :

#### Examples

    var im = new mapnik.Image(5, 5);
                im.filter("blur", function(err, im_res) {
                  if (err) throw err;
                  assert.equal(im_res.getPixel(0, 0), 1);
                });

`#filterSync(filter)`

Filter this image

## filterSync(filter)

`src/mapnik_image.cpp`

Filter this image

#### Parameters

- `string` filter :

`#getPixel(x, y, options)`

## getPixel(x, y, options)

`src/mapnik_image.cpp`

#### Parameters

- `number` x :

  position within image from top left

- `number` y :

  position within image from top left

- `Object` options :

  the only valid option is `get_color`, which should be a `boolean`.

#### Returns

``number`` :

color

#### Examples

    var im = new mapnik.Image(256, 256);
                var view = im.view(0, 0, 256, 256);
                var pixel = view.getPixel(0, 0, {get_color:true});
                assert.equal(pixel.r, 0);
                assert.equal(pixel.g, 0);
                assert.equal(pixel.b, 0);
                assert.equal(pixel.a, 0);

`#getType`

Determine the image type

## getType

`src/mapnik_image.cpp`

Determine the image type

#### Returns

``number`` :

Number of the image type

`#height`

Get this image's height

## height

`src/mapnik_image.cpp`

Get this image's height

#### Returns

``number`` :

height

`#isSolidSync`

Determine whether the image is solid - whether it has alpha values of greater than one.

## isSolidSync

`src/mapnik_image.cpp`

Determine whether the image is solid - whether it has alpha values of greater than one.

#### Returns

``boolean`` :

whether the image is solid

#### Examples

    var im = new mapnik.Image(256, 256);
                var view = im.view(0, 0, 256, 256);
                assert.equal(view.isSolidSync(), true);

`#premultiplied`

Determine whether the given image is premultiplied.

## premultiplied

`src/mapnik_image.cpp`

Determine whether the given image is premultiplied.

#### Returns

``boolean`` :

premultiplied true if the image is premultiplied

`#premultiply(callback)`

Premultiply the pixels in this image, asynchronously

## premultiply(callback)

`src/mapnik_image.cpp`

Premultiply the pixels in this image, asynchronously

#### Parameters

- `Function` callback :

`#premultiplySync`

Premultiply the pixels in this image

## premultiplySync

`src/mapnik_image.cpp`

Premultiply the pixels in this image

`#resize(width, height, [options], callback)`

Create a copy this image that is resized

## resize(width, height, [options], callback)

`src/mapnik_image.cpp`

Create a copy this image that is resized

#### Parameters

- `number` width :
- `number` height :
- `[`Object`]` options (default `{}`) :
- `Function` callback :

`#resizeSync(width, height, [options])`

Make a resized copy of an image

## resizeSync(width, height, [options])

`src/mapnik_image.cpp`

Make a resized copy of an image

#### Parameters

- `number` width :
- `number` height :
- `[`Object`]` options (default `{}`) :

#### Returns

``mapnik.Image`` :

copy

`#save(filename, [format], callback)`

Encode this image and save it to disk as a file.

## save(filename, [format], callback)

`src/mapnik_image.cpp`

Encode this image and save it to disk as a file.

#### Parameters

- `string` filename :
- `[`string`]` format (default `png`) :
- `Function` callback :

`#saveSync(filename, [format])`

Encode this image and save it to disk as a file.

## saveSync(filename, [format])

`src/mapnik_image.cpp`

Encode this image and save it to disk as a file.

#### Parameters

- `string` filename :
- `[`string`]` format (default `png`) :

#### Examples

    myImage.saveSync('foo.png');

`#setPixel(x, y, numeric)`

## setPixel(x, y, numeric)

`src/mapnik_image.cpp`

#### Parameters

- `number` x :

  position within image from top left

- `number` y :

  position within image from top left

- `Object` or `number` numeric :

  or object representation of a color

`#view(x, y, width, height)`

Get a constrained view of this image given x, y, width, height parameters.

## view(x, y, width, height)

`src/mapnik_image.cpp`

Get a constrained view of this image given x, y, width, height parameters.

#### Parameters

- `number` x :
- `number` y :
- `number` width :
- `number` height :

#### Returns

``mapnik.Image`` :

an image constrained to this new view

`#width`

Get this image's width

## width

`src/mapnik_image.cpp`

Get this image's width

#### Returns

``number`` :

width

## mapnik.ImageView(left, top, width, height)

`src/mapnik_image_view.cpp`

This is usually not initialized directly: you'll use the `mapnik.Image#view` method to instantiate an instance.

#### Parameters

- `number` left :
- `number` top :
- `number` width :
- `number` height :

#### Throws

- `TypeError`:

  if any argument is missing or not numeric

#### Examples

    var im = new mapnik.Image(256, 256);
    var view = im.view(0, 0, 256, 256);

## mapnik.Map(width, width, projection)

`src/mapnik_map.cpp`

A map in mapnik is an object that combined data sources and styles in a way that lets you produce styled cartographic output.

#### Parameters

- `number` width :
- `number` width :
- `string` projection :

  as a proj4 code

#### Examples

    var map = new mapnik.Map(25, 25, '+init=epsg:3857');

#### Instance members

`#add_layer(new)`

Add a new layer to this map

## add_layer(new)

`src/mapnik_map.cpp`

Add a new layer to this map

#### Parameters

- `mapnik.Layer` new :

  layer

`#clear`

Remove all layers and styles from this map

## clear

`src/mapnik_map.cpp`

Remove all layers and styles from this map

`#clone`

Clone this map object, returning a value which can be changed without mutating the original

## clone

`src/mapnik_map.cpp`

Clone this map object, returning a value which can be changed without mutating the original

#### Returns

``mapnik.Map`` :

clone

`#font`

Get all of the fonts currently registered as part of this map

## font

`src/mapnik_map.cpp`

Get all of the fonts currently registered as part of this map

`#fontDirectory`

Get the currently-registered font directory, if any

## fontDirectory

`src/mapnik_map.cpp`

Get the currently-registered font directory, if any

#### Returns

``string` or` :

fonts

`#fontFiles`

Get all of the fonts currently registered as part of this map, as a mapping from font to font file

## fontFiles

`src/mapnik_map.cpp`

Get all of the fonts currently registered as part of this map, as a mapping from font to font file

#### Returns

``Object`` :

fonts

`#fromStringSync(stylesheet, [options], callback)`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet given as a string.

## fromStringSync(stylesheet, [options], callback)

`src/mapnik_map.cpp`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet given as a string.

#### Parameters

- `string` stylesheet :

  contents

- `[`Object`]` options (default `{}`) :
- `Function` callback :

#### Examples

    var fs = require('fs');
                map.fromStringSync(fs.readFileSync('./style.xml', 'utf8'), function(err, res) {
                  // details loaded
                });

`#fromStringSync(stylesheet, [options])`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet given as a string.

## fromStringSync(stylesheet, [options])

`src/mapnik_map.cpp`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet given as a string.

#### Parameters

- `string` stylesheet :

  contents

- `[`Object`]` options (default `{}`) :

#### Examples

    var fs = require('fs');
                map.fromStringSync(fs.readFileSync('./style.xml', 'utf8'));

`#get_layer(layer)`

Get a layer out of this map, given a name or index

## get_layer(layer)

`src/mapnik_map.cpp`

Get a layer out of this map, given a name or index

#### Parameters

- `string` or `number` layer :

  name or index

#### Returns

``mapnik.Layer`` :

the layer

#### Throws

- `Error`:

  if index is incorrect or layer is not found

`#layers`

Get all of the currently-added layers in this map

## layers

`src/mapnik_map.cpp`

Get all of the currently-added layers in this map

`#load(stylesheet, [options], callback)`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet.

## load(stylesheet, [options], callback)

`src/mapnik_map.cpp`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet.

#### Parameters

- `string` stylesheet :

  path

- `[`Object`]` options (default `{}`) :
- `Function` callback :

`#loadSync(stylesheet, [options])`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet.

## loadSync(stylesheet, [options])

`src/mapnik_map.cpp`

Load styles, layers, and other information for this map from a Mapnik XML stylesheet.

#### Parameters

- `string` stylesheet :

  path

- `[`Object`]` options (default `{}`) :

#### Examples

    map.loadSync('./style.xml');

`#resize(width, height)`

Give this map new dimensions

## resize(width, height)

`src/mapnik_map.cpp`

Give this map new dimensions

#### Parameters

- `number` width :
- `number` height :

`#scale`

Get the map's scale factor. This is the ratio between pixels and geographical units like meters.

## scale

`src/mapnik_map.cpp`

Get the map's scale factor. This is the ratio between pixels and geographical units like meters.

#### Returns

``number`` :

scale

`#scaleDenominator`

Get the map's scale denominator.

## scaleDenominator

`src/mapnik_map.cpp`

Get the map's scale denominator.

#### Returns

``number`` :

scale denominator

## mapnik.Projection(projection, [options])

`src/mapnik_projection.cpp`

A geographical projection: this class makes it possible to translate between locations in different projections

#### Parameters

- `string` projection :

  projection as a proj4 definition string

- `[`Object`]` options (default `{lazy:false}`) :

  whether to lazily instantiate the data backing this projection.

#### Throws

- `TypeError`:

  if the projection string or options argument is the wrong type

- `Error`:

  the projection could not be initialized - it was not found in proj4's tables or the string was malformed

#### Examples

    var wgs84 = new mapnik.Projection('+init=epsg:4326');

#### Instance members

`#forward`

Project from a position in WGS84 space to a position in this projection.

## forward

`src/mapnik_projection.cpp`

Project from a position in WGS84 space to a position in this projection.

`#inverse`

Unproject from a position in this projection to the same position in WGS84 space.

## inverse

`src/mapnik_projection.cpp`

Unproject from a position in this projection to the same position in WGS84 space.

## mapnik.VectorTile(z, x, y)

`src/mapnik_vector_tile.cpp`

A generator for the Mapbox Vector Tile specification of compressed and simplified tiled vector data

#### Parameters

- `number` z :
- `number` x :
- `number` y :

#### Examples

    var vtile = new mapnik.VectorTile(9,112,195);

#### Instance members

`#addData(raw, name)`

Add raw data to this tile as a Buffer

## addData(raw, name)

`src/mapnik_vector_tile.cpp`

Add raw data to this tile as a Buffer

#### Parameters

- `Buffer` raw :

  data

- `string` name :

  of the layer to be added

`#addGeoJSON(geojson, name)`

Add features to this tile from a GeoJSON string

## addGeoJSON(geojson, name)

`src/mapnik_vector_tile.cpp`

Add features to this tile from a GeoJSON string

#### Parameters

- `string` geojson :

  as a string

- `string` name :

  of the layer to be added

`#clear(callback)`

Remove all data from this vector tile

## clear(callback)

`src/mapnik_vector_tile.cpp`

Remove all data from this vector tile

#### Parameters

- `Function` callback :

`#compositeSync`

Composite an array of vector tiles into one vector tile

## compositeSync

`src/mapnik_vector_tile.cpp`

Composite an array of vector tiles into one vector tile

`#empty(whether)`

Return whether this vector tile is empty - whether it has no layers and no features

## empty(whether)

`src/mapnik_vector_tile.cpp`

Return whether this vector tile is empty - whether it has no layers and no features

#### Parameters

- `boolean` whether :

  the layer is empty

`#getData(map, renderable, callback)`

Render this vector tile to a surface, like a `mapnik.Image`

## getData(map, renderable, callback)

`src/mapnik_vector_tile.cpp`

Render this vector tile to a surface, like a `mapnik.Image`

#### Parameters

- `mapnik.Map` map :

  object

- `mapnik.Image` renderable :

  surface

- `Function` callback :

`#getDataSync`

Get the data in this vector tile as a buffer

## getDataSync

`src/mapnik_vector_tile.cpp`

Get the data in this vector tile as a buffer

#### Returns

``Buffer`` :

raw data

`#height(height)`

Get the vector tile's height

## height(height)

`src/mapnik_vector_tile.cpp`

Get the vector tile's height

#### Parameters

- `number` height :

`#isSolid(callback)`

Test whether this tile is solid - whether it has features

## isSolid(callback)

`src/mapnik_vector_tile.cpp`

Test whether this tile is solid - whether it has features

#### Parameters

- `Function` callback :

`#isSolidSync`

Test whether this tile is solid - whether it has features

## isSolidSync

`src/mapnik_vector_tile.cpp`

Test whether this tile is solid - whether it has features

#### Returns

``boolean`` :

whether the tile is solid

`#names`

Get the names of all of the layers in this vector tile

## names

`src/mapnik_vector_tile.cpp`

Get the names of all of the layers in this vector tile

`#painted(painted)`

Get whether the vector tile has been painted

## painted(painted)

`src/mapnik_vector_tile.cpp`

Get whether the vector tile has been painted

#### Parameters

- `boolean` painted :

`#query(longitude, latitude, [options], callback)`

Query a vector tile by longitude and latitude

## query(longitude, latitude, [options], callback)

`src/mapnik_vector_tile.cpp`

Query a vector tile by longitude and latitude

#### Parameters

- `number` longitude :
- `number` latitude :
- `[`Object`]` options (default `{tolerance:0}`) :

  tolerance: allow results that are not exactly on this longitude, latitude position.

- `Function` callback :

`#reportGeometrySimplicity(callback)`

Count the number of non OGC simple geometries

## reportGeometrySimplicity(callback)

`src/mapnik_vector_tile.cpp`

Count the number of non OGC simple geometries

#### Parameters

- `Function` callback :

`#reportGeometrySimplicitySync`

Count the number of geometries that are not OGC simple

## reportGeometrySimplicitySync

`src/mapnik_vector_tile.cpp`

Count the number of geometries that are not OGC simple

#### Returns

``number`` :

number of features that are not simple

`#reportGeometryValidity(callback)`

Count the number of non OGC valid geometries

## reportGeometryValidity(callback)

`src/mapnik_vector_tile.cpp`

Count the number of non OGC valid geometries

#### Parameters

- `Function` callback :

`#reportGeometryValiditySync`

Count the number of geometries that are not OGC valid

## reportGeometryValiditySync

`src/mapnik_vector_tile.cpp`

Count the number of geometries that are not OGC valid

#### Returns

``number`` :

number of features that are not valid

`#setData(raw, name)`

Replace the data in this vector tile with new raw data

## setData(raw, name)

`src/mapnik_vector_tile.cpp`

Replace the data in this vector tile with new raw data

#### Parameters

- `Buffer` raw :

  data

- `string` name :

  of the layer to be added

`#toGeoJSON(callback)`

Get a GeoJSON representation of this tile

## toGeoJSON(callback)

`src/mapnik_vector_tile.cpp`

Get a GeoJSON representation of this tile

#### Parameters

- `Function` callback :

#### Returns

``string`` :

stringified GeoJSON of all the features in this tile.

`#toGeoJSONSync`

Get a GeoJSON representation of this tile

## toGeoJSONSync

`src/mapnik_vector_tile.cpp`

Get a GeoJSON representation of this tile

#### Returns

``string`` :

stringified GeoJSON of all the features in this tile.

`#toJSON`

Get a JSON representation of this tile

## toJSON

`src/mapnik_vector_tile.cpp`

Get a JSON representation of this tile

#### Returns

``Object`` :

json representation of this tile with name, extent, and version properties

`#width(width)`

Get the vector tile's width

## width(width)

`src/mapnik_vector_tile.cpp`

Get the vector tile's width

#### Parameters

- `number` width :

## mapnik.blend

`src/blend.cpp`

Composite multiple images on top of each other, with strong control over how the images are combined, resampled, and blended.