Bangkok District Geocoding

A lightweight library to find the Bangkok district based on latitude and longitude coordinates.
Features
- Fast and Efficient: Quickly find a district from geographic coordinates.
- Offline: No network requests needed; all data is included in the package.
- TypeScript Support: Fully typed for a better development experience.
Data Source
The geographic data for Bangkok's 50 districts is sourced from the official Open Government Data of Bangkok website:
The original data was provided in Shapefile format and was converted to GeoJSON using mygeodata.cloud.
Installation
pnpm install bkk-district-geocoding
npm install bkk-district-geocoding
yarn add bkk-district-geocoding
Usage
import { getDistrictFromLatLng } from 'bkk-district-geocoding'
const latitude = 13.7563
const longitude = 100.5018
const district = getDistrictFromLatLng(latitude, longitude)
if (district) {
console.log(`The district is: ${district.properties.dname}`)
console.log(`District Code: ${district.properties.dcode}`)
} else {
console.log('No district found for the given coordinates.')
}
Development
This project uses pnpm
as the package manager.
pnpm install
- Install dependencies
pnpm dev
- Start the development server
pnpm build
- Build for production
pnpm test
- Run all tests
License
MIT