geo-peru
v1.1.0
Published
Peru ubigeo data from RENIEC — departments, provinces, and districts
Downloads
78
Maintainers
Readme
geo-peru
Peru's ubigeo data from RENIEC. Includes departments, provinces, and districts with coordinates and area.
Installation
npm install geo-peru
# or
yarn add geo-peruUsage
import {
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
// }API
getDepartments()
Returns all 25 departments.
interface Department {
code: string; // "01"–"25"
name: string;
}getProvinces(departmentCode?)
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"
}getDistricts(provinceCode?)
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
}getByUbigeo(ubigeo)
Returns the district with the given ubigeo, or undefined if not found.
getLocation(ubigeo)
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" }Department codes
| 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 | | |
Data
- 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)
License
MIT
