1.0.6 • Published 1 year ago

@fuzzysaj/location-to-usa-county v1.0.6

Weekly downloads
4
License
GPL-3.0
Repository
github
Last release
1 year ago

@fuzzysaj/location-to-usa-county

npm (scoped) Build Status dependencies Status code coverage

A program to convert latitude/longitude coordinates into USA counties. Data is stored locally based on publicly available boundary files from United States Census Bureau.

Install

$ npm install @fuzzysaj/location-to-usa-county

Usage

With JavaScript:

const getLocToCountyLookupService = require('@fuzzysaj/location-to-usa-county');

(async ()=> {
  const locToCounty = await getLocToCountyLookupService(); 
  const county = await locToCounty(33.5038, -112.0253); // latitude, longitude for Phoenix
  // -> { county_name: "Maricopa", county_fips: "04013" }
})();

With TypeScript:

import { getLocToCountyLookupService, County } from '@fuzzysaj/location-to-usa-county'

(async ()=> {
  const locToCounty = await getLocToCountyLookupService();
  const county: County = await locToCounty(33.5038, -112.0253); // latitude, longitude for Phoeinx
  // -> { county_name: "Maricopa", county_fips: "04013" }
})();

About

2018 US counties boundaries obtained from United States Census Bureau in Shapefile format. Shapefile was converted to GeoJson and downsampled to 10% of original size using mapshaper.