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.
$ npm install @fuzzysaj/location-to-usa-county
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" }
})();
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.