https://github.com/mapbox/tippecanoe
Raw File
Tip revision: e1655941cc2d1d35d1b7f7a8d4b0fbc8215ac6d6 authored by Eric Fischer on 17 October 2016, 20:53:52 UTC
Add a test where the base zoom is beyond the max zoom
Tip revision: e165594
tippecanoe.1
.TH tippecanoe
.PP
Builds vector tilesets \[la]https://www.mapbox.com/developers/vector-tiles/\[ra] from large (or small) collections of GeoJSON \[la]http://geojson.org/\[ra] features,
like these \[la]MADE_WITH.md\[ra]\&.
.PP
[Build Status](https://travis\-ci.org/mapbox/tippecanoe.svg) \[la]https://travis-ci.org/mapbox/tippecanoe\[ra]
[Coverage Status](https://coveralls.io/repos/mapbox/tippecanoe/badge.svg?branch=master&service=github) \[la]https://coveralls.io/github/mapbox/tippecanoe?branch=master\[ra]
.SH Intent
.PP
The goal of Tippecanoe is to enable making a scale\-independent view of your data,
so that at any level from the entire world to a single building, you can see
the density and texture of the data rather than a simplification from dropping
supposedly unimportant features or clustering or aggregating them.
.PP
If you give it all of OpenStreetMap and zoom out, it should give you back
something that looks like "All Streets \[la]http://benfry.com/allstreets/map5.html\[ra]"
rather than something that looks like an Interstate road atlas.
.PP
If you give it all the building footprints in Los Angeles and zoom out
far enough that most individual buildings are no longer discernable, you
should still be able to see the extent and variety of development in every neighborhood,
not just the largest downtown buildings.
.PP
If you give it a collection of years of tweet locations, you should be able to
see the shape and relative popularity of every point of interest and every
significant travel corridor.
.SH Installation
.PP
The easiest way to install tippecanoe on OSX is with Homebrew \[la]http://brew.sh/\[ra]:
.PP
.RS
.nf
$ brew install tippecanoe
.fi
.RE
.SH Usage
.PP
.RS
.nf
$ tippecanoe \-o file.mbtiles [file.json ...]
.fi
.RE
.PP
If no files are specified, it reads GeoJSON from the standard input.
If multiple files are specified, each is placed in its own layer.
.PP
The GeoJSON features need not be wrapped in a FeatureCollection.
You can concatenate multiple GeoJSON features or files together,
and it will parse out the features and ignore whatever other objects
it encounters.
.SH Options
.SS Naming
.RS
.IP \(bu 2
\-l \fIname\fP or \-\-layer=\fIname\fP: Layer name (default "file" if source is file.json or output is file.mbtiles). If there are multiple input files
specified, the files are all merged into the single named layer, even if they try to specify individual names with \-L.
.IP \(bu 2
\-L \fIname\fP:\fIfile.json\fP or \-\-named\-layer=\fIname\fP:\fIfile.json\fP: Specify layer names for individual files. If your shell supports it, you can use a subshell redirect like \-L \fIname\fP:<(cat dir/*.json) to specify a layer name for the output of streamed input.
.IP \(bu 2
\-n \fIname\fP or \-\-name=\fIname\fP: Human\-readable name for the tileset (default file.json)
.IP \(bu 2
\-A \fItext\fP or \-\-attribution=\fItext\fP: Attribution (HTML) to be shown with maps that use data from this tileset.
.RE
.SS File control
.RS
.IP \(bu 2
\-o \fIfile\fP\&.mbtiles or \-\-output=\fIfile\fP\&.mbtiles: Name the output file.
.IP \(bu 2
\-f or \-\-force: Delete the mbtiles file if it already exists instead of giving an error
.IP \(bu 2
\-F or \-\-allow\-existing: Proceed (without deleting existing data) if the metadata or tiles table already exists
or if metadata fields can't be set
.IP \(bu 2
\-t \fIdirectory\fP or \-\-temporary\-directory=\fIdirectory\fP: Put the temporary files in \fIdirectory\fP\&.
If you don't specify, it will use \fB\fC/tmp\fR\&.
.IP \(bu 2
\-P or \-\-read\-parallel: Use multiple threads to read different parts of each input file at once.
This will only work if the input is line\-delimited JSON with each Feature on its
own line, because it knows nothing of the top\-level structure around the Features. Spurious "EOF" error
messages may result otherwise.
Performance will be better if the input is a named file that can be mapped into memory
rather than a stream that can only be read sequentially.
.RE
.SS Zoom levels and resolution
.RS
.IP \(bu 2
\-z \fIzoom\fP or \-\-maximum\-zoom=\fIzoom\fP: Maxzoom: the highest zoom level for which tiles are generated (default 14)
.IP \(bu 2
\-Z \fIzoom\fP or \-\-minimum\-zoom=\fIzoom\fP: Minzoom: the lowest zoom level for which tiles are generated (default 0)
.IP \(bu 2
\-B \fIzoom\fP or \-\-base\-zoom=\fIzoom\fP: Base zoom, the level at and above which all points are included in the tiles (default maxzoom).
If you use \-Bg, it will guess a zoom level that will keep at most 50,000 features in the densest tile.
You can also specify a marker\-width with \-Bg\fIwidth\fP to allow fewer features in the densest tile to
compensate for the larger marker, or \-Bf\fInumber\fP to allow at most \fInumber\fP features in the densest tile.
.IP \(bu 2
\-d \fIdetail\fP or \-\-full\-detail=\fIdetail\fP: Detail at max zoom level (default 12, for tile resolution of 4096)
.IP \(bu 2
\-D \fIdetail\fP or \-\-low\-detail=\fIdetail\fP: Detail at lower zoom levels (default 12, for tile resolution of 4096)
.IP \(bu 2
\-m \fIdetail\fP or \-\-minimum\-detail=\fIdetail\fP: Minimum detail that it will try if tiles are too big at regular detail (default 7)
.IP \(bu 2
\-b \fIpixels\fP or \-\-buffer=\fIpixels\fP: Buffer size where features are duplicated from adjacent tiles. Units are "screen pixels"\-\-1/256th of the tile width or height. (default 5)
.IP \(bu 2
\-s \fIprojection\fP or \-\-projection=\fIprojection\fP: Specify the projection of the input data. Currently supported are EPSG:4326 (WGS84, the default) and EPSG:3857 (Web Mercator).
.RE
.PP
All internal math is done in terms of a 32\-bit tile coordinate system, so 1/(2 of the size of Earth,
or about 1cm, is the smallest distinguishable distance. If \fImaxzoom\fP + \fIdetail\fP > 32, no additional
resolution is obtained than by using a smaller \fImaxzoom\fP or \fIdetail\fP\&.
.SS Properties
.RS
.IP \(bu 2
\-x \fIname\fP or \-\-exclude=\fIname\fP: Exclude the named properties from all features
.IP \(bu 2
\-y \fIname\fP or \-\-include=\fIname\fP: Include the named properties in all features, excluding all those not explicitly named
.IP \(bu 2
\-X or \-\-exclude\-all: Exclude all properties and encode only geometries
.RE
.SS Point simplification
.RS
.IP \(bu 2
\-r \fIrate\fP or \-\-drop\-rate=\fIrate\fP: Rate at which dots are dropped at zoom levels below basezoom (default 2.5).
If you use \-rg, it will guess a drop rate that will keep at most 50,000 features in the densest tile.
You can also specify a marker\-width with \-rg\fIwidth\fP to allow fewer features in the densest tile to
compensate for the larger marker, or \-rf\fInumber\fP to allow at most \fInumber\fP features in the densest tile.
.IP \(bu 2
\-g \fIgamma\fP or \-\-gamma=\fIgamma\fP: Rate at which especially dense dots are dropped (default 0, for no effect). A gamma of 2 reduces the number of dots less than a pixel apart to the square root of their original number.
.RE
.SS Line and polygon simplification
.RS
.IP \(bu 2
\-S \fIscale\fP or \-\-simplification=\fIscale\fP: Multiply the tolerance for line and polygon simplification by \fIscale\fP\&. The standard tolerance tries to keep
the line or polygon within one tile unit of its proper location. You can probably go up to about 10 without too much visible difference.
.RE
.SS Doing more
.RS
.IP \(bu 2
\-ac or \-\-coalesce: Coalesce adjacent line and polygon features that have the same properties.
Note that when overlapping polygons are coalesced, the overlapping region is treated as a hole,
which may not be what you want.
.IP \(bu 2
\-ar or \-\-reverse: Try reversing the directions of lines to make them coalesce and compress better
.IP \(bu 2
\-ao or \-\-reorder: Reorder features to put ones with the same properties in sequence, to try to get them to coalesce
.IP \(bu 2
\-al or \-\-drop\-lines: Let "dot" dropping at lower zooms apply to lines too
.IP \(bu 2
\-ap or \-\-drop\-polygons: Let "dot" dropping at lower zooms apply to polygons too
.IP \(bu 2
\-ag or \-\-calculate\-feature\-density: Add a new attribute, \fB\fCtippecanoe_feature_density\fR, to each feature, to record how densely features are spaced in that area of the tile. You can use this attribute in the style to produce a glowing effect where points are densely packed. It can range from 0 in the sparsest areas to 255 in the densest.
.IP \(bu 2
\-ab or \-\-detect\-shared\-borders: In the manner of TopoJSON \[la]https://github.com/mbostock/topojson/wiki/Introduction\[ra], detect borders that are shared between multiple polygons and simplify them identically in each polygon. This takes more time and memory than considering each polygon individually.
.RE
.SS Doing less
.RS
.IP \(bu 2
\-ps or \-\-no\-line\-simplification: Don't simplify lines
.IP \(bu 2
\-pS or \-\-simplify\-only\-low\-zooms: Don't simplify lines at maxzoom (but do simplify at lower zooms)
.IP \(bu 2
\-pf or \-\-no\-feature\-limit: Don't limit tiles to 200,000 features
.IP \(bu 2
\-pk or \-\-no\-tile\-size\-limit: Don't limit tiles to 500K bytes
.IP \(bu 2
\-pd or \-\-force\-feature\-limit: Dynamically drop some fraction of features from large tiles to keep them under the 500K size limit. It will probably look ugly at the tile boundaries.
.IP \(bu 2
\-pi or \-\-preserve\-input\-order: Preserve the original input order of features as the drawing order instead of ordering geographically. (This is implemented as a restoration of the original order at the end, so that dot\-dropping is still geographic, which means it also undoes \-ao).
.IP \(bu 2
\-pp or \-\-no\-polygon\-splitting: Don't split complex polygons (over 700 vertices after simplification) into multiple features.
.IP \(bu 2
\-pc or \-\-no\-clipping: Don't clip features to the size of the tile. If a feature overlaps the tile's bounds or buffer at all, it is included completely. Be careful: this can produce very large tilesets, especially with large polygons.
.IP \(bu 2
\-pD or \-\-no\-duplication: As with \-\-no\-clipping, each feature is included intact instead of cut to tile boundaries. In addition, it is included only in a single tile per zoom level rather than potentially in multiple copies. Clients of the tileset must check adjacent tiles (possibly some distance away) to ensure they have all features.
.IP \(bu 2
\-q or \-\-quiet: Work quietly instead of reporting progress
.RE
.SH Example
.PP
.RS
.nf
$ tippecanoe \-o alameda.mbtiles \-l alameda \-n "Alameda County from TIGER" \-z13 tl_2014_06001_roads.json
.fi
.RE
.PP
.RS
.nf
$ cat tiger/tl_2014_*_roads.json | tippecanoe \-o tiger.mbtiles \-l roads \-n "All TIGER roads, one zoom" \-z12 \-Z12 \-d14 \-x LINEARID \-x RTTYP
.fi
.RE
.SH GeoJSON extension
.PP
Tippecanoe defines a GeoJSON extension that you can use to specify the minimum and/or maximum zoom level
at which an individual feature will be included in the vector tileset being produced.
If you have a feature like this:
.PP
.RS
.nf
{
    "type" : "Feature",
    "tippecanoe" : { "maxzoom" : 9, "minzoom" : 4 },
    "properties" : { "FULLNAME" : "N Vasco Rd" },
    "geometry" : {
        "type" : "LineString",
        "coordinates" : [ [ \-121.733350, 37.767671 ], [ \-121.733600, 37.767483 ], [ \-121.733131, 37.766952 ] ]
    }
}
.fi
.RE
.PP
with a \fB\fCtippecanoe\fR object specifiying a \fB\fCmaxzoom\fR of 9 and a \fB\fCminzoom\fR of 4, the feature
will only appear in the vector tiles for zoom levels 4 through 9. Note that the \fB\fCtippecanoe\fR
object belongs to the Feature, not to its \fB\fCproperties\fR\&.
.PP
You can also specify a layer name in the \fB\fCtippecanoe\fR object, which will take precedence over
the filename or name specified using \fB\fC\-\-layer\fR, like this:
.PP
.RS
.nf
{
    "type" : "Feature",
    "tippecanoe" : { "layer" : "streets" },
    "properties" : { "FULLNAME" : "N Vasco Rd" },
    "geometry" : {
        "type" : "LineString",
        "coordinates" : [ [ \-121.733350, 37.767671 ], [ \-121.733600, 37.767483 ], [ \-121.733131, 37.766952 ] ]
    }
}
.fi
.RE
.SH Point styling
.PP
To provide a consistent density gradient as you zoom, the Mapbox Studio style needs to be
coordinated with the base zoom level and dot\-dropping rate. You can use this shell script to
calculate the appropriate marker\-width at high zoom levels to match the fraction of dots
that were dropped at low zoom levels.
.PP
If you used \fB\fC\-B\fR or \fB\fC\-z\fR to change the base zoom level or \fB\fC\-r\fR to change the
dot\-dropping rate, replace them in the \fB\fCbasezoom\fR and \fB\fCrate\fR below.
.PP
.RS
.nf
awk 'BEGIN {
    dotsize = 2;    # up to you to decide
    basezoom = 14;  # tippecanoe \-z 14
    rate = 2.5;     # tippecanoe \-r 2.5

    print "  marker\-line\-width: 0;";
    print "  marker\-ignore\-placement: true;";
    print "  marker\-allow\-overlap: true;";
    print "  marker\-width: " dotsize ";";
    for (i = basezoom + 1; i <= 22; i++) {
        print "  [zoom >= " i "] { marker\-width: " (dotsize * exp(log(sqrt(rate)) * (i \- basezoom))) "; }";
    }

    exit(0);
}'
.fi
.RE
.SH Geometric simplifications
.PP
At every zoom level, line and polygon features are subjected to Douglas\-Peucker
simplification to the resolution of the tile.
.PP
For point features, it drops 1/2.5 of the dots for each zoom level above the
point base zoom (which is normally the same as the \fB\fC\-z\fR max zoom, but can be
a different zoom specified with \fB\fC\-B\fR if you have precise but sparse data).
I don't know why 2.5 is the appropriate number, but the densities of many different
data sets fall off at about this same rate. You can use \-r to specify a different rate.
.PP
You can use the gamma option to thin out especially dense clusters of points.
For any area where dots are closer than one pixel together (at whatever zoom level),
a gamma of 3, for example, will reduce these clusters to the cube root of their original density.
.PP
For line features, it drops any features that are too small to draw at all.
This still leaves the lower zooms too dark (and too dense for the 500K tile limit,
in some places), so I need to figure out an equitable way to throw features away.
.PP
Any polygons that are smaller than a minimum area (currently 4 square subpixels) will
have their probability diffused, so that some of them will be drawn as a square of
this minimum size and others will not be drawn at all, preserving the total area that
all of them should have had together.
.PP
Any polygons that have over 700 vertices after line simplification will be split into
multiple features so they can be rendered efficiently, unless you use \-pp to prevent this.
.PP
Features in the same tile that share the same type and attributes are coalesced
together into a single geometry if you use \fB\fC\-\-coalesce\fR\&. You are strongly encouraged to use \-x to exclude
any unnecessary properties to reduce wasted file size.
.PP
If a tile is larger than 500K, it will try encoding that tile at progressively
lower resolutions before failing if it still doesn't fit.
.SH Development
.PP
Requires sqlite3 and zlib (should already be installed on MacOS). Rebuilding the manpage
uses md2man (\fB\fCgem install md2man\fR).
.PP
Linux:
.PP
.RS
.nf
sudo apt\-get install libsqlite3\-dev zlib1g\-dev
.fi
.RE
.PP
Then build:
.PP
.RS
.nf
make
.fi
.RE
.PP
and perhaps
.PP
.RS
.nf
make install
.fi
.RE
.SH Examples
.PP
Check out some examples of maps made with tippecanoe \[la]MADE_WITH.md\[ra]
.SH Name
.PP
The name is a joking reference \[la]http://en.wikipedia.org/wiki/Tippecanoe_and_Tyler_Too\[ra] to a "tiler" for making map tiles.
.SH tile\-join
.PP
Tile\-join is a tool for joining new attributes from a CSV file to features that
have already been tiled with tippecanoe. It reads the tiles from an existing .mbtiles
file, matches them against the records of the CSV, and writes out a new tileset.
.PP
If you specify multiple source mbtiles files, they are all read and their combined
contents are written to the new mbtiles output. If they define the same layers or
the same tiles, the layers or tiles are merged.
.PP
The options are:
.RS
.IP \(bu 2
\-o \fIout.mbtiles\fP: Write the new tiles to the specified .mbtiles file
.IP \(bu 2
\-f: Remove \fIout.mbtiles\fP if it already exists
.IP \(bu 2
\-c \fImatch.csv\fP: Use \fImatch.csv\fP as the source for new attributes to join to the features. The first line of the file should be the key names; the other lines are values. The first column is the one to match against the existing features; the other columns are the new data to add.
.IP \(bu 2
\-x \fIkey\fP: Remove attributes of type \fIkey\fP from the output. You can use this to remove the field you are matching against if you no longer need it after joining, or to remove any other attributes you don't want.
.IP \(bu 2
\-i: Only include features that matched the CSV.
.IP \(bu 2
\-pk: Don't skip tiles larger than 500K.
.RE
.PP
Because tile\-join just copies the geometries to the new .mbtiles without processing them
(except to rescale the extents if necessary),
it doesn't have any of tippecanoe's recourses if the new tiles are bigger than the 500K tile limit.
If a tile is too big and you haven't specified \fB\fC\-pk\fR, it is just left out of the new tileset.
.SH Example
.PP
Imagine you have a tileset of census blocks:
.PP
.RS
.nf
curl \-O http://www2.census.gov/geo/tiger/TIGER2010/TABBLOCK/2010/tl_2010_06001_tabblock10.zip
unzip tl_2010_06001_tabblock10.zip
ogr2ogr \-f GeoJSON tl_2010_06001_tabblock10.json tl_2010_06001_tabblock10.shp
\&./tippecanoe \-o tl_2010_06001_tabblock10.mbtiles tl_2010_06001_tabblock10.json
.fi
.RE
.PP
and a CSV of their populations:
.PP
.RS
.nf
curl \-O http://www2.census.gov/census_2010/01\-Redistricting_File\-\-PL_94\-171/California/ca2010.pl.zip
unzip \-p ca2010.pl.zip cageo2010.pl |
awk 'BEGIN {
    print "GEOID10,population"
}
(substr($0, 9, 3) == "750") {
    print "\\"" substr($0, 28, 2) substr($0, 30, 3) substr($0, 55, 6) substr($0, 62, 4) "\\"," (0 + substr($0, 328, 9))
}' > population.csv
.fi
.RE
.PP
which looks like this:
.PP
.RS
.nf
GEOID10,population
"060014277003018",0
"060014283014046",0
"060014284001020",0
\&...
"060014507501001",202
"060014507501002",119
"060014507501003",193
"060014507501004",85
\&...
.fi
.RE
.PP
Then you can join those populations to the geometries and discard the no\-longer\-needed ID field:
.PP
.RS
.nf
\&./tile\-join \-o population.mbtiles \-x GEOID10 \-c population.csv tl_2010_06001_tabblock10.mbtiles
.fi
.RE
.SH tippecanoe\-enumerate
.PP
The \fB\fCtippecanoe\-enumerate\fR utility lists the tiles that an \fB\fCmbtiles\fR file defines.
Each line of the output lists the name of the \fB\fCmbtiles\fR file and the zoom, x, and y
coordinates of one of the tiles. It does basically the same thing as
.PP
.RS
.nf
select zoom_level, tile_column, (1 << zoom_level) \- 1 \- tile_row from tiles;
.fi
.RE
.PP
on the file in sqlite3.
.SH tippecanoe\-decode
.PP
The \fB\fCtippecanoe\-decode\fR utility turns vector mbtiles back to GeoJSON. You can use it either
on an entire file:
.PP
.RS
.nf
tippecanoe\-decode file.mbtiles
.fi
.RE
.PP
or on an individual tile:
.PP
.RS
.nf
tippecanoe\-decode file.mbtiles zoom x y
tippecanoe\-decode file.vector.pbf zoom x y
.fi
.RE
.PP
If you decode an entire file, you get a nested \fB\fCFeatureCollection\fR identifying each
tile and layer separately. Note that the same features generally appear at all zooms,
so the output for the file will have many copies of the same features at different
resolutions.
.SS Options
.RS
.IP \(bu 2
\-t \fIprojection\fP: Specify the projection of the output data. Currently supported are EPSG:4326 (WGS84, the default) and EPSG:3857 (Web Mercator).
.RE
back to top