This assumes you already successfully installed TileStache on your machine, then placed the data file in /data
folder. Let's say our data file name is test.geojson
and we want to put generated geojson tiles under /built-tiles
.
Open the tilestache.cfg
and edit the content of it like this:
(If you don't want to gzip your tile, take geojson
out from gzip
field.)
{
"cache":
{
"name": "Disk",
"path": "built-tiles/",
"umask": "0000",
"dirs": "portable",
"gzip": ["xml", "geojson"]
},
"layers":
{
"test-tiles":
{
"provider": {
"name": "vector", "driver": "GeoJSON",
"parameters": {"file": "data/test.geojson"}
}
}
}
}
Then you should be able to excute command like this (This command assumes the tiles need to be generated in the bound of NorthEast: [37.7627, 127.3975] SouthWest: [37.3633, 126.6268]
, and in 14, 15
zoom level) :
sudo python ./scripts/tilestache-seed.py -b 37.7627 127.3975 37.3633 126.6268 -c tilestache.cfg -l test-tiles 14 15
If you decided to gzip your tile, you would notice that built tiles have geojson.gz
extension. Not all browsers know how to deal with gzip encoding, (only applying via Accepts
header) I needed to change these extension to just geojson
via a command below. (on Mac OS X)
find . -name '*.geojson.gz' -exec sh -c 'mv "$0" "${0%.geojson.gz}.geojson"' {} \;
When serving the tile, make sure Content-Encoding
set as gzip
. (If you are using s3 bucket gui, it lets you choose it while uploading)
- geojson2mvt(https://github.com/NYCPlanning/geojson2mvt)
If your data is bigger than 100mb, and you need high zoom tiles, you are going to be suprised how long time it takes to generate static vector tiles. So, plan what you would/wouldn't need from tiles and prepare your data accordingly.