Return the area (NT, Kowloon, HK, Island) of a given coorindates
🏠 Homepage
npm install hk-area
yarn add hk-area
import getHKArea from "hk-area";
let area = getHKArea(22.203350936422417, 113.86662909332935);
console.log(area); // HK
getHKArea(lat, long);
Parameters:
Name | Type | Required | Description |
---|---|---|---|
lat | double | Yes | Latitude in WGS84 Coordinates |
long | double | Yes | Longitude in WGS84 Coordinates |
yarn test
The boundaries data is based on HKGov's Hong Kong Geodata Store, specifically the Boundary Plan of District Lands Office.
The original boundaries definition is too large (1.5MB after minified), for sake of performance and package size, the boundaries definition are simplified using mapshaper. Therefore, some locations near the edge of the area (particularly between NT and Kowloon) might not be accurate. But it's good enough for most of the use case.
All coordinates has been converted from HK1980 to WGS84 coordinates.
Github: @alanho
This README was generated with ❤️ by readme-md-generator