1.2.1 • Published 5 years ago

us-counties v1.2.1

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

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

FieldLengthTypeDescription
STATEFP102String2010 Census state FIPS code
ANRCFP105String2010 Census Alaska Native Regional Corporation FIPS code
ANRCNS108String2010 Census Alaska Native Regional Corporation ANSI code
GEOID107StringAlaska Native Regional Corporation identifier; a concatenation of 2010 Census state FIPS code and Alaska Native Regional Corporation code
NAME10100String2010 Census Alaska Native Regional Corporation name
NAMELSAD10100String2010 Census name and the translated legal/statistical area description for Alaska Native Regional Corporation
LSAD102String2010 Census legal/statistical area description code for Alaska Native Regional Corporation
CLASSFP102String2010 Census FIPS class code
MTFCC105StringMAF/TIGER feature class code (G2200)
FUNCSTAT101String2010 Census functional status
ALAND1014Number2010 Census land area
AWATER1014Number2010 Census water area
INTPTLAT1011String2010 Census latitude of the internal point
INTPTLON1012String2010 Census longitude of the internal point

License

MIT

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago