NP nepalboundaries.py
Administrative boundaries of Nepal for Python — country, province, district, municipality, and ward level, all in a single pip install.
Inspired by rgeoboundaries but tailored specifically for Nepal — standardised column names, WGS84 projection, and hierarchical filtering baked in.
[logo]
Installation
# From GitHub (latest)
pip install git+https://github.com/Lalitgis/nepalboundariespy.git
# From PyPI (when published)
pip install nepalboundariespy
# With visualisation extras (matplotlib + folium)
pip install nepalboundariespy[viz]
Requirements: Python ≥ 3.8, geopandas ≥ 0.10, shapely ≥ 1.8, pandas ≥ 1.0
Quick start
import nepalboundariespy as nb
# All 7 provinces
provinces = nb.get_province()
provinces.plot(figsize=(12, 8), edgecolor="black", alpha=0.6)
# All 77 districts
districts = nb.get_district()
# Districts in one province
bagmati = nb.get_district(province="Bagmati")
# Wards in Kathmandu
ktm_wards = nb.get_ward(municipality="Kathmandu")
print(f"Kathmandu has {len(ktm_wards)} wards")
# Check what's available
nb.list_levels()
# {'country': 1, 'province': 7, 'district': 77, 'municipality': 753, 'ward': 6743}
API reference
Boundary functions
| Function | Description |
|---|---|
get_country() |
Nepal national boundary |
get_province(province=None) |
Provincial boundaries (7 total) |
get_district(district=None, province=None) |
District boundaries (77 total) |
get_municipality(municipality=None, district=None, province=None) |
Municipality boundaries (753 total) |
get_ward(ward=None, municipality=None, district=None, province=None) |
Ward boundaries (6 743 total) |
get_multiple(levels=['province','district']) |
Fetch multiple levels at once → dict |
All functions accept a single string or a list of strings for each filter parameter.
Utility functions
| Function | Description |
|---|---|
list_levels() |
Feature counts for all levels |
info(level) |
One-row summary (count, columns, CRS) |
clear_cache() |
Free in-memory cache |
Convenience aliases
get_prov → get_province · get_dist → get_district · get_mun → get_municipality
Examples
Filtering
import nepalboundariespy as nb
# Single filter
bhaktapur = nb.get_district("Bhaktapur")
# Multiple at once
two_provinces = nb.get_province(["Bagmati", "Gandaki"])
# Hierarchical filter — municipalities inside a specific district
patan_mun = nb.get_municipality(district="Lalitpur")
# All wards in province 3 (Bagmati)
bagmati_wards = nb.get_ward(province="Bagmati")
Plotting
import matplotlib.pyplot as plt
import nepalboundariespy as nb
fig, axes = plt.subplots(1, 2, figsize=(16, 6))
nb.get_province().plot(ax=axes[0], edgecolor="black", alpha=0.6)
axes[0].set_title("Provinces of Nepal")
nb.get_district(province="Bagmati").plot(ax=axes[1], edgecolor="black", alpha=0.6)
axes[1].set_title("Districts in Bagmati Province")
plt.tight_layout()
plt.show()
Interactive map with Folium
import folium
import nepalboundariespy as nb
m = folium.Map(location=[28.3949, 84.1240], zoom_start=7)
folium.GeoJson(
nb.get_district().to_json(),
name="Districts",
tooltip=folium.GeoJsonTooltip(fields=["district_name", "province_name"]),
).add_to(m)
folium.LayerControl().add_to(m)
m.save("nepal_districts.html")
Spatial analysis
import geopandas as gpd
from shapely.geometry import Point
import nepalboundariespy as nb
# Point-in-polygon: which district contains Kathmandu Durbar Square?
point = gpd.GeoDataFrame(
{"geometry": [Point(85.3157, 27.7044)]}, crs="EPSG:4326"
)
match = gpd.sjoin(point, nb.get_district(), how="left", predicate="within")
print(match["district_name"].values[0]) # → Kathmandu
# Neighbouring districts
ktm = nb.get_district("Kathmandu").iloc[0]
neighbours = nb.get_district()[nb.get_district().touches(ktm.geometry)]
print(neighbours["district_name"].tolist())
Export data
import nepalboundariespy as nb
districts = nb.get_district()
districts.to_file("nepal_districts.geojson", driver="GeoJSON")
districts.to_file("nepal_districts.gpkg", driver="GPKG")
districts.to_file("nepal_districts.shp")
# Attribute table only (no geometry)
districts.drop(columns="geometry").to_csv("nepal_districts.csv", index=False)
Data structure
Nepal (Country)
└── 7 Provinces
└── 77 Districts
└── 753 Municipalities / Rural Municipalities + Procted Areas of Nepal
└── 6743 Wards
All data is projected to WGS84 (EPSG:4326).
Column names by level
| Level | Key columns |
|---|---|
| country | geometry |
| province | province_name, province_code, area_km2, geometry |
| district | district_name, district_code, province_name, area_km2, geometry |
| municipality | municipality_name, municipality_code, district_name, province_name, area_km2, geometry |
| ward | ward_number, municipality_name, district_name, province_name, geometry |
Preparing/updating the data
The package expects GeoJSON files in nepalboundaries/data/.
Use the provided script to convert your raw boundary files:
# Edit the paths inside the script, then run:
python scripts/data_preparation_python.py
Repository structure
nepalboundariespy/ ← GitHub repo root
├── nepalboundariespy/ ← Python package
│ ├── __init__.py
│ ├── core.py
│ └── data/
│ ├── country.geojson
│ ├── province.geojson
│ ├── district.geojson
│ ├── municipality.geojson
│ └── ward.geojson
├── tests/
│ └── test_nepalboundaries.py
├── examples/
│ └── examples_Python_usage.py
├── scripts/
│ └── data_preparation_python.py
├── setup.py
├── MANIFEST.in
├── LICENSE
├── CHANGELOG.md
└── README.md
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-improvement - Make your changes and add tests
- Run the test suite:
pytest tests/ -v - Open a Pull Request
License
MIT — see LICENSE for details.
Citation
@software{nepalboundariespy2026,
title = {nepalboundariespy: Administrative Boundaries of Nepal},
author = {BC Lalit},
year = {2026},
url = {https://github.com/Lalitgis/nepalboundariespy}
}
Related resources
- Nepal CBS — Central Bureau of Statistics
- HDX Nepal — Humanitarian Data Exchange
- OpenStreetMap Nepal
- rgeoboundaries — R package that inspired this
Metadata
Release files for nepalboundariespy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nepalboundariespy-0.1.0.tar.gz | 28.1 MB | With provenance | Details for nepalboundariespy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nepalboundariespy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nepalboundariespy-0.1.0-py3-none-any.whl |
Total release size: 56.3 MB
Release files / nepalboundariespy-0.1.0.tar.gz
| Download URL | nepalboundariespy-0.1.0.tar.gz |
|---|---|
| Size | 28.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8cbf3fac1ac397815993a285c55b15fed1fe57674b9db6e9247379889800d876
|
|
BLAKE2b-256 checksum How to use checksums |
b1e43b9f5c40bd1fd0bd62b9679f198aecd9706e87a3f2333202a6eada6f4a27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 30, 2026.
Transparency logRelease files / nepalboundariespy-0.1.0-py3-none-any.whl
| Download URL | nepalboundariespy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 28.2 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
84b141d639b7a8854cda01b2a23303564ad96c305de2512c71b9d004a17f86be
|
|
BLAKE2b-256 checksum How to use checksums |
085a573ee7cf66fa82deac2ec67b2b273b16ffe0f95d95e33bb72ffc155574dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 30, 2026.
Transparency logSecurity for nepalboundariespy 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for nepalboundariespy-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 30, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.