Skip to content

This converts Mapnik Vector Tile geometries to latlon or spherical Mercator list of coordinates.

License

Notifications You must be signed in to change notification settings

jimmyrocks/mapnik-vector-tile-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mapnik Vector Tiles to GeoJSON Converter

mapnik-vector-tile-converter

This converts Mapnik Vector Tile geometries to GeoJSON format.

Background

I was curious how Mapnik Vector Tiles are constructed, and I figured the best way to determine that is by deconstructing them. I found a great library that was 90% to my goal, and I added in code to create GeoJSON from it. If you are looking for production ready code, I'd forward you to Node Mapnik, but if you're looking to learn more about how Mapik Vector tiles work, this is the place!

Dependancies

This code is written in NodeJS, and it installs the package Protobuf.js.

Example

This example:

  • Loads tiles from MapBox Streets Vector Tiles
  • Converts them to geojson using this library
  • Draws them on a Map using D3

Warning

This example uses the MapBox Streets Vector Tile layer from the MapBox servers, it is only for development.

Example Usage

git clone https://github.com/jimmyrocks/mapnik-vector-tile-converter.git
cd mapnik-vector-tile-converter
npm install
cd example
node server.js

Open: http://localhost:8080 in your favorite browser. (It's really SVG/D3 heavy, so I'd suggest Chrome)

Usage

No docs on this yet, but you can look at the server.js file in the examples directory to get an idea on how it is converting the pbf Vector Tile files to GeoJSON.

Development

Run tests

mocha tests

Director

Calls the appropriate functions (moveTo, lineTo and/or closePath as described in the Mapnik's vector_tile.proto) for a Mapnik Vector Tile geometry.

Builder

Returns the geometry of the tile (= relative coordinates) from MoveTo, LineTo and ClosePath commands.

Converter

Changes the geometry relative to the tile into a latitude longitude or Mercator-projected x y list.

Notes from vross

This project was made as I tried to understand how PBF tiles work. I had not heard about Node-Mapnik, which is (really) more efficient to convert PBF tiles to another format. The idea here was to decode PBF tiles in Node and then browserify all the code to use it client-side and get a geometry usable with Leaflet. It should be possible to improve the code to have better performances, but I'm almost sure it will never be as efficient as a server-side PBF decoding in Node with C++ bindings.

About

This converts Mapnik Vector Tile geometries to latlon or spherical Mercator list of coordinates.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published