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

us-counties

v1.2.1

Published

A GeoJSON object containing geometries of every county in the US

Downloads

23

Readme

US Counties

A GeoJSON object containing geometries of every county in the US.

Data courtesy of https://github.com/jgoodall/us-maps, which was derived from US Census shapefiles.

Installation

npm install us-counties

:warning: This module loads a ~170MB JSON object into memory, so your mileage may vary. See server usage or consider running your process with the v8 max-old-space-size flag, like node -–max-old-space-size=8192 your-file.js.

Programmatic Usage

This module plays nicely with the which-polygon package for looking up counties by lng/lat coordinate:

const counties = require('us-counties')
const whichPolygon = require('which-polygon')
const findCounty = whichPolygon(counties)
const coords = [-109.82152075444654, 33.987415215464544]
const result = findCounty(coords)

Results look like this:

{ STATEFP10: '04',
  COUNTYFP10: '001',
  COUNTYNS10: '00025441',
  GEOID10: '04001',
  NAME10: 'Apache',
  NAMELSAD10: 'Apache County',
  LSAD10: '06',
  CLASSFP10: 'H1',
  MTFCC10: 'G4020',
  CSAFP10: null,
  CBSAFP10: null,
  METDIVFP10: null,
  FUNCSTAT10: 'A',
  ALAND10: 29001443825,
  AWATER10: 54175788,
  INTPTLAT10: '+35.3858453',
  INTPTLON10: '-109.4937467',
  state: 'AZ' }

Server Usage :rocket:

If you're writing a program that is already hungry for RAM, you can avoid out-of-memory errors by running this module as a webserver in a separate process:

$ npx us-counties

Now there's a server running on port 5000. Make requests by passing lng and lat as query params, like localhost:5000/?lng=-109.82152075444654&lat=33.987415215464544

npm i -g json
curl -s "http://localhost:5000/?lng=-109.82152075444654&lat=33.987415215464544" | json

Fields

From https://www2.census.gov/geo/pdfs/maps-data/data/tiger/tgrshp2010/TGRSHP10SF1AA.pdf

Field | Length | Type | Description --- | --- | --- | --- STATEFP10 | 2 | String | 2010 Census state FIPS code ANRCFP10 | 5 | String | 2010 Census Alaska Native Regional Corporation FIPS code ANRCNS10 | 8 | String | 2010 Census Alaska Native Regional Corporation ANSI code GEOID10 | 7 | String | Alaska Native Regional Corporation identifier; a concatenation of 2010 Census state FIPS code and Alaska Native Regional Corporation code NAME10 | 100 | String | 2010 Census Alaska Native Regional Corporation name NAMELSAD10 | 100 | String | 2010 Census name and the translated legal/statistical area description for Alaska Native Regional Corporation LSAD10 | 2 | String | 2010 Census legal/statistical area description code for Alaska Native Regional Corporation CLASSFP10 | 2 | String | 2010 Census FIPS class code MTFCC10 | 5 | String | MAF/TIGER feature class code (G2200) FUNCSTAT10 | 1 | String | 2010 Census functional status ALAND10 | 14 | Number | 2010 Census land area AWATER10 | 14 | Number | 2010 Census water area INTPTLAT10 | 11 | String | 2010 Census latitude of the internal point INTPTLON10 | 12 | String | 2010 Census longitude of the internal point

License

MIT