Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nepal_geo_data-0.1.1.tar.gz (548.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nepal_geo_data-0.1.1-py3-none-any.whl (545.3 kB view details)

Uploaded Python 3

File details

Details for the file nepal_geo_data-0.1.1.tar.gz.

File metadata

  • Download URL: nepal_geo_data-0.1.1.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

Hashes for nepal_geo_data-0.1.1.tar.gz
Algorithm Hash digest
SHA256 46bb112e279a5650ab1428d3fe4032ec4a14cd96996b4823dd9ef717e937e1b1
MD5 f132ca148e20b3a3ace9f116cef27707
BLAKE2b-256 a23a51b85f6a4e4c271c0ceec0cf601a323a3c5dd975e4f43fe535f8d8024693

See more details on using hashes here.

File details

Details for the file nepal_geo_data-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nepal_geo_data-0.1.1-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

Hashes for nepal_geo_data-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c47e22502ccfe7bb0fd40855b62706084f4726e6c3a992c3f8bb81333bb78152
MD5 3fb9c62253be22ce4e1991e27e42a6e3
BLAKE2b-256 deb48dffa8eecd7c97450005799c9b8752a1a929c8f600f780525a08ed4ef368

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page