A Python package providing geographical data (GeoJSON) for Nepal's districts and provinces.
Project description
Nepal Geo Data
A Python package that bundles GeoJSON data for Nepal's districts and provinces, providing a simple and efficient API to access geographical data without handling external files.
Installation
pip install nepal-geo-data
Quick Start
import nepal_geo_data
# Get all district names
print(nepal_geo_data.get_districts())
# Get data for a specific district
ktm = nepal_geo_data.get_district("Kathmandu")
print(ktm['properties'])
detailed Usability & API Reference
1. Retrieve District Keys
Get a sorted list of all 77 districts in uppercase. Useful for populating dropdowns or validation.
from nepal_geo_data import get_districts
districts = get_districts()
# Output: ['ACHHAM', 'ARGHAKHANCHI', ..., 'UDAYAPUR']
2. Get District Details
Search for a district by name (case-insensitive). Returns a GeoJSON Feature dictionary containing properties and geometry.
from nepal_geo_data import get_district
data = get_district('Lalitpur')
if data:
# Access Properties
props = data['properties']
print(f"District: {props['DISTRICT']}")
print(f"Headquarters: {props['HQ']}")
print(f"Province ID: {props['PROVINCE']}")
# Access Geometry
geometry = data['geometry']
print(f"Type: {geometry['type']}") # e.g., Polygon
3. Get Districts by Province
Filter districts based on their Province ID (1-7).
from nepal_geo_data import get_province_districts
# Get all districts in Bagmati Province (Province 3)
province_3_districts = get_province_districts(3)
print(province_3_districts)
# Output: ['BHAKTAPUR', 'CHITWAN', 'DHADING', 'DOLAKHA', 'KATHMANDU', 'KAVREPALANCHOK', 'LALITPUR', 'MAKWANPUR', 'NUWAKOT', 'RAMECHHAP', 'RASUWA', 'SINDHULI', 'SINDHUPALCHOK']
4. Get Province Data
Get a list of all 7 provinces with their metadata.
from nepal_geo_data import get_provinces
provinces = get_provinces()
for p in provinces:
print(f"Province {p['id']}: {p['name']} (Capital: {p['capital']})")
5. Access Raw GeoJSON
If you need the full GeoJSON object for plotting (e.g., with Plotly, Folium, or GeoPandas), you can fetch the raw data directly.
from nepal_geo_data import get_geojson
data = get_geojson()
# data is a dictionary representing the FeatureCollection
# {'type': 'FeatureCollection', 'features': [...]}
Integration Examples
Plotting with Plotly Express
import plotly.express as px
from nepal_geo_data import get_geojson
geo_data = get_geojson()
fig = px.choropleth_mapbox(
geojson=geo_data,
locations=['KATHMANDU', 'LALITPUR', 'BHAKTAPUR'], # Example subset
featureidkey="properties.DISTRICT",
mapbox_style="carto-positron",
center={"lat": 27.7, "lon": 85.3},
zoom=7
)
fig.show()
Development
To install locally for development:
git clone https://github.com/bedbyaspokhrel/nepal-geo-data.git
cd nepal-geo-data
pip install -e .
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nepal_geo_data-0.1.2.tar.gz.
File metadata
- Download URL: nepal_geo_data-0.1.2.tar.gz
- Upload date:
- Size: 548.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50412538bd64e9bc0b0081c0cc44ac9f48b0fcafc228363a20e8c2c83ffeae72
|
|
| MD5 |
2d7a26288d162da89256cfbc923c987f
|
|
| BLAKE2b-256 |
2a415405842c3ee58e8a43e10e170036ebfc15b4ccb58ea6a19d7ca097f6ede3
|
File details
Details for the file nepal_geo_data-0.1.2-py3-none-any.whl.
File metadata
- Download URL: nepal_geo_data-0.1.2-py3-none-any.whl
- Upload date:
- Size: 545.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5b713bef0bd5305050ac9887e2b5583dd529f0b767009e0bbcb1c25e75a74cf
|
|
| MD5 |
7a02c6dd74ef44269b98d0e6e6f83b3e
|
|
| BLAKE2b-256 |
4564bf0043958afad8f684b5f6ecae0d0fb63bd36378e8b9a4ad907eeeb2b204
|