Geography and maps
Distances and nearest cities
Section titled “Distances and nearest cities”import { getDistance, getNearestCities } from '@code-plate/iran-cities';
getDistance('tehran', 'karaj'); // 36.5 kmgetNearestCities({ lat: 29.6, lng: 52.5 }, { limit: 1 }); // [{ city: شیراز, distanceKm: 5.6 }]getNearestCities('tehran', { limit: 5, minConfidence: 'high' });Neighbors
Section titled “Neighbors”import { getNeighborProvinces, areNeighborProvinces } from '@code-plate/iran-cities';
getNeighborProvinces('قم'); // [اصفهان, مرکزی, سمنان, تهران]areNeighborProvinces('yazd', 'south-khorasan'); // trueNeighbors are computed from the province boundaries (a shared border of at least 3 km) and reflect current borders, including the 2013 move of Tabas county to South Khorasan.
Which province is this point in?
Section titled “Which province is this point in?”import { getProvinceAt, provinceBoundaries } from '@code-plate/iran-cities/boundaries';
getProvinceAt({ lat: 34.64, lng: 50.88 }); // قمgetProvinceAt({ lat: 48.85, lng: 2.35 }); // undefined (outside Iran)Points within 5 km of a province (islands, the coast) are matched to the nearest one; change this with { maxDistanceKm }. Every city with coordinates resolves to its own province.
provinceBoundaries is a standard GeoJSON FeatureCollection you can pass straight to Leaflet, MapLibre or deck.gl. The same file is available as @code-plate/iran-cities/data/iran-provinces.geojson.