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/yourusername/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.0.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.0-py3-none-any.whl (545.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nepal_geo_data-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 2d2115fcc5720606052bd67e57c5654ff68d6dd25544dd0a6718e50d82dc7a5f
MD5 d2243cf8529c88c83580360a67dbfeb2
BLAKE2b-256 f8fba9823f2252fb37b4cf0dc1d4096d356e7bb2a63ac9f9ca002ddd65717500

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nepal_geo_data-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d05f56f4b703113006fd8f2ab898589750f7df015df2b5d11c7bcb65abfb848
MD5 52a6fe779585a901e48a19b9b998ee68
BLAKE2b-256 2235b4250672e2b61994b7f273dc7205ded1dc2419bb6abed97fa79cd2127dc2

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