Peru's ubigeo data from RENIEC. Includes departments, provinces, and districts with coordinates and area.
npm install geo-peru
# or
yarn add geo-peruimport {
getDepartments,
getProvinces,
getDistricts,
getByUbigeo,
} from "geo-peru";
// List all 25 departments
const departments = getDepartments();
// [{ code: "01", name: "Amazonas" }, ...]
// Provinces of a department (Lima = "14")
const provinces = getProvinces("14");
// [{ code: "1401", name: "Lima", departmentCode: "14" }, ...]
// All districts in the country
const districts = getDistricts();
// Districts of a province (Lima = "1401")
const limaDistricts = getDistricts("1401");
// Look up by ubigeo
const district = getByUbigeo("140101");
// {
// ubigeo: "140101",
// name: "Lima",
// provinceCode: "1401",
// departmentCode: "14",
// area: 21.98,
// lat: -12.0467,
// lon: -77.0322
// }Returns all 25 departments.
interface Department {
code: string; // "01"–"25"
name: string;
}Returns all provinces, or those of a given department if departmentCode is provided.
interface Province {
code: string; // 4 digits: "0101"
name: string;
departmentCode: string; // 2 digits: "01"
}Returns all districts, or those of a given province if provinceCode is provided.
interface District {
ubigeo: string; // 6 digits: "010101"
name: string;
provinceCode: string; // 4 digits: "0101"
departmentCode: string; // 2 digits: "01"
area: number; // km²
lat: number; // centroid latitude
lon: number; // centroid longitude
}Returns the district with the given ubigeo, or undefined if not found.
Returns the department, province, and district names for a given 6-digit ubigeo, or undefined if not found.
interface Location {
department: string;
province: string;
district: string;
}
getLocation("150101");
// { department: "Loreto", province: "Maynas", district: "Iquitos" }| Code | Department | Code | Department |
|---|---|---|---|
| 01 | Amazonas | 14 | Lima |
| 02 | Ancash | 15 | Loreto |
| 03 | Apurimac | 16 | Madre de Dios |
| 04 | Arequipa | 17 | Moquegua |
| 05 | Ayacucho | 18 | Pasco |
| 06 | Cajamarca | 19 | Piura |
| 07 | Cusco | 20 | Puno |
| 08 | Huancavelica | 21 | San Martin |
| 09 | Huanuco | 22 | Tacna |
| 10 | Ica | 23 | Tumbes |
| 11 | Junin | 24 | Callao |
| 12 | La Libertad | 25 | Ucayali |
| 13 | Lambayeque |
- Source: RENIEC / GEODIR
- Last updated: January 15, 2019
- Coverage: 25 departments · 195 provinces · 1,838 districts
- Ubigeo: 6-digit code (
DD PP ZZ— department, province, district)
MIT