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

@whosonfirst/wof

v0.54.0

Published

WhosOnFirst tools

Downloads

60

Readme

[BETA] This repo is still a work-in-progress.

Installation

npm i -g @whosonfirst/wof

Dependencies

To avoid reinventing the wheel, some code in this repo will 'shell out' to execute a common *nix command line application instead of native javascript code.

Ideally we'd like to only depend on utilities which come standard on most *nix systems, but it might be the case that your environment lacks one or more of these programs:

# check dependencies
which cat find node git bzip2 gzip pv bsdtar docker
# ubuntu
sudo apt-get install git bzip2 gzip pv libarchive-tools docker

# mac OSX
brew install git bzip2 gzip pv libarchive docker

CLI

wof --help
wof <cmd> [args]

Commands:
  wof bundle   interact with tar bundles
  wof feature  misc functions for working with feature streams
  wof fs       interact with files in the filesystem
  wof git      interact with git repositories
  wof sqlite   interact with SQLite databases

Options:
  --version      Show version number                                   [boolean]
  --verbose, -v  enable verbose logging               [boolean] [default: false]
  --help         Show help                                             [boolean]

Git

interact with git repositories

  wof git export <repo>  export features from a git repo
  wof git list <repo>    list paths in a git repo

Supported Repository Types

Both 'bare' and 'checkout' style clones are supported, these commands use the git archive command and so do not require the geojson files to be present in the filesystem.

If you don't need a working copy of the files you can save disk space by using a --bare style clone.

The following command uses only 661M of disk space, compared to 3.8G for the equivalent 'checkout' style clone which also extracts ~400k files to the filesystem.

git clone \
  --bare \
  --depth 1 \
  --single-branch \
  --branch master \
  https://github.com/whosonfirst-data/whosonfirst-data-admin-us.git us-bare

Git List

list paths in a git repo

wof git list /data/wof

... list of geojson files
wof git list /data/wof --path data/101/914/241/101914241.geojson

... list of geojson files matching the path argument

Git Export

export features from a git repo

wof git export /data/wof

... stream of geojson features
wof git export /data/wof --path data/101/914/241/101914241.geojson

... stream of geojson features matching the path argument

SQLite

interact with SQLite databases

  wof sqlite export <db>  export features from a SQLite database
  wof sqlite import <db>  import features into a SQLite database

SQLite Export

export features from a SQLite database

wof sqlite export wof.db

... stream of geojson features

Provide a custom SQL statement with --sql, or use one of the built-in aliases @all (default) or @exportable:

wof sqlite export --sql='@exportable' wof.db

SQLite Import

import features into a SQLite database

cat 101914243.geojson | wof sqlite import --rm wof.db

Feature Tools

misc functions for working with feature streams

  wof feature format        reformat a feature stream
  wof feature map <script>  apply user-provided map function to features
  wof feature ogr <dst>     export features using ogr2ogr
  wof feature properties    output feature properties
  wof feature stats         generate aggregate stats

Feature Reformatting

reformat a feature stream

cat jsonstream | wof feature format

... stream of minified json, one item per line
cat jsonstream | wof feature format --open $'[\n' --sep $'\n,\n' --close $'\n]'

... stream of minified json, with array header, footer and separator
cat 101914243.geojson | wof feature format --indent 2

... stream of pretty printed json

Feature Mapping

provide a javascript mapping function to rewrite the output stream

# my-custom-mapper.js
module.exports = (feat, params) => feat
cat jsonstream | wof feature map my-custom-mapper.js

... stream of json after the map function has been applied

parameters can be passed to the view as either a JSON object:

# using 'params' (note the plural)
cat jsonstream | wof feature map my-custom-mapper.js \
  --params='{"foo": "bar", "faz": "baz"}'

or as key/value pairs:

# using 'param'
cat jsonstream | wof feature map my-custom-mapper.js \
  --param="foo=bar" \
  --param='faz=baz'

Some built-in views are bundled in the whosonfirst/views directory:

cat jsonstream | wof feature map \
  view://shapefile.js \
  --param="placetype=locality" \
  --param='geom=.*point'

... stream of json after the map function has been applied

GDAL (ogr2ogr)

a convenience command for piping a feature stream into ogr2ogr:

cat jsonstream | wof feature ogr example.shp --format='Esri Shapefile'
cat jsonstream | wof feature ogr example.gpkg --format='GPKG'

see: https://gdal.org/programs/ogr2ogr.html

Feature Properties

output feature properties

cat 101914243.geojson | wof feature properties -p 'wof:id' -p 'wof:placetype'

{"wof:id":101914243,"wof:placetype":"locality"}

Feature Stats

generate aggregate stats

cat 101914243.geojson | wof feature stats

{"locality":1}