npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vtile

v1.0.2

Published

A simple Node and command line tool to create vector tiles (directory or mbtiles) in JavaScript from one or more geojson files using geojson2mvt, geojson-vt, and TurfJS.

Downloads

76

Readme

vtile

A simple Node and command line tool to create vector tiles (directory or mbtiles) in JavaScript from one or more geojson files using geojson2mvt, geojson-vt, and TurfJS.

npm install vtile -g

Then to create vector tiles for a single file:

vtile -i "./data/ohio.geojson" -f directory

For large input files increase the available Node memory --max-old-space-size=8192.

For a directory of files simple call vtile in the directory of geojson files or point it to a directory:

vtile -d "./data/"

Benchmarks for Formats

Writing to mbtiles is 10x-70x faster!

Directory

-Z 15 -i ohio.geojson -f directory

Done! I made 168030 tiles!
tiles done at 158.639 seconds

MBTiles

-Z 15 -i ohio.geojson -f mbtiles

Done! I made 168030 tiles!
tiles done at 3.933 seconds

v 1.0.0

  • Breaking Changes -f is now -i and -f translates to the output format, either -f mbtiles or -f directory.
  • Added writing vector tiles to mbtiles format using better-sqlite3.
  • The mbtiles output can be viewed with mbview or any mbtiles server.

v 0.2.0

  • vtile now writes tiles by default, just use the -f option vtile -f data/ohio.geojson and tiles will be created in a 'tiles' folder in the working directory.
  • Preview map zooms to the layer extent.
  • Features are given a numeric, ascending feature id to use with the Mapbox GL JS feature state.
  • geojson-vt has been updated to the latest version.

v 0.1.7 vtile adds a field called vtlid to each feature called vtlid which is a unique identifier for each feature - if this conflicts with a field you already have you will need to edit the vtile.js file

v 0.1.4 vtile will delete one or more fields from your geojson, and optionally output that geojson file

v 0.1.3 vtile will tile all geojson files in a folder, with the layer names in the tiles being the file names. If you just want to convert one file, simply add that file -f "./data/ohio.geojson".

Tiles are created in a '/tiles/your file name/' folder in the current working directory, both of which can be configured. A tilejson is created in the '/tiles/your file name/' folder, and if -p is added, an index page is created in the '/tiles/' folder and opened to preview the tiles. If tiling all files in a folder, the preview only will add the first file.

For options use vtile -h.

Usage: command [options]
    --format, -f          output format, choices are mbtiles or directory (default: directory)
    --input, -i           your geojson file if not using directory option
    --tiles-dir, -t       directory to store the vector tiles (default: "tiles/")
    --geojson-dir, -d     directory of GeoJSON files you want to convert (default './')
    --minzoom, -z         min zoom level to build tiles (default: 0)
    --maxzoom, -Z         max zoom to build tiles (tiles will overzoom in mapbox gl, leaflet and ol3) (default: 5)
    --extract, -x         remove these properties from the geojson file(s), one for each field, i.e -x "COUNTY" -x "Shape_Length"
    --output, -o          output the geojson file(s), useful if using the extract option
    --write, -w           vtile will not write any tiles with -w false (default: true)
    --preview, -p         writes an index.html page in the tiles dir to preview your tiles (default: false)
    --resume, -r          vtile will delete all the files and folders in the tiles directory unless this is true (default: false)
    --help, -h            show help

This project uses TurfJS to automate vector tile creation in JavaScript using geojson2mvt, which uses geojson-vt internally.

Sample GeoJSON file from here - http://eric.clst.org/tech/usgeojson/