boundaries

Source for all GeoJSON boundaries on Earth

Usage no npm install needed!

<script type="module">
  import boundaries from 'https://cdn.skypack.dev/boundaries';
</script>

README

boundaries NPM version Downloads

GeoJSON boundaries for Earth, masterfully formatted and normalized for your consumption.

Total # as of writing this: 40,106

Usage

  • Use the NPM module to retrieve and access the data (instructions below)
  • Use this repo as a submodule and write your own thing to load the data (just a bunch of json files!)
  • Link directly to the files on GitHub

Using one of these methods, the boundaries are accessible on any language or platform. Enjoy!

Sources

  • Neighborhoods
    • Zillow
  • States/Cities/Counties/Zip Codes
    • US Census Bureau (TIGER 2016)

Mostly US boundaries right now (data availability), but would love to add more around the world. Know of more good sources for boundary data? Send a PR!

Boundary JSON Format

  • id (String)
    • Unique ID for this boundary
  • type (String)
    • state, neighborhood, county, etc.
  • name (String)
    • Display Name
  • area (Object)
    • GeoJSON MultiPolygon
    • No simplification, original precision

Node Modules

Install

npm install boundaries

API

  • listSync()
    • Synchronous
    • Returns an array of boundary file paths
  • readSync(path)
    • Synchronous
    • Returns a object representing the boundary for the given path
  • list([cb])
    • Asynchronous form of listSync
    • Callback is optional, returns a promise
  • read(path[, cb])
    • Asynchronous form of readSync
    • Callback is optional, returns a promise

Example

Simple example of listing boundaries and reading them synchronously.

ES5

var boundaries = require('boundaries');
var fs = require('fs');

var files = boundaries.listSync();

files.forEach(function(filePath) {
  var boundary = boundaries.readSync(filePath);
  // Do something with it!
});

ES6

import { listSync, readSync } from 'boundaries'

const files = listSync()

files.forEach((filePath) => {
  const boundary = readSync(filePath)
  // Do something with it!
})