Skip to content

Locations API

Location data for districts and blocks, plus GeoJSON boundary overlays for the map. These endpoints are used to populate dropdown menus, build navigation, and render district / protected-area outlines.

The district and block lists are read from the block shapefile (Dist_Name, Block_name). Assam has 35 districts and 220 blocks.


Get Location Hierarchy

Returns the district → block hierarchy. Each district also carries a blocks array, and the response includes a flat blocks list for backward compatibility. Districts are sorted alphabetically.

GET /api/locations

Response

{
  "districts": [
    {
      "name": "CACHAR",
      "blocks": [
        { "name": "BINNAKANDI (CACHAR)" },
        { "name": "LAKHIPUR (CACHAR)" }
      ]
    },
    {
      "name": "DIBRUGARH",
      "blocks": [
        { "name": "BARBARUAH" },
        { "name": "LAHOWAL" }
      ]
    }
  ],
  "blocks": [
    { "district": "CACHAR", "block_name": "BINNAKANDI (CACHAR)" },
    { "district": "CACHAR", "block_name": "LAKHIPUR (CACHAR)" },
    { "district": "DIBRUGARH", "block_name": "BARBARUAH" }
  ]
}
Field Type Description
districts array Districts, sorted alphabetically
districts[].name string District name (from shapefile Dist_Name)
districts[].blocks array Blocks in this district
districts[].blocks[].name string Block name
blocks array Flat list of all blocks with their district (backward compatibility)
blocks[].district string District name
blocks[].block_name string Block name

Errors

Code Description
500 Server error — returns {"error": "<message>"}

Example

curl https://leaf-asrlm.in/api/locations
import requests

r = requests.get("https://leaf-asrlm.in/api/locations")
data = r.json()

for district in data['districts']:
    print(f"{district['name']}: {len(district['blocks'])} blocks")
    for block in district['blocks']:
        print(f"  └─ {block['name']}")
const r = await fetch('/api/locations');
const data = await r.json();

// Build district dropdown
data.districts.forEach(d => {
  const option = document.createElement('option');
  option.value = d.name;
  option.textContent = d.name;
  districtSelect.appendChild(option);
});

Get All Districts

Returns all districts with block counts. Districts are sorted alphabetically.

GET /api/districts

Response

{
  "districts": [
    {
      "name": "BAJALI",
      "block_count": 3
    },
    {
      "name": "BAKSA",
      "block_count": 7
    }
  ]
}
Field Type Description
districts[].name string District name
districts[].block_count integer Number of blocks in this district

Errors

Code Description
500 Server error — returns {"error": "<message>"}

Example

curl https://leaf-asrlm.in/api/districts
import requests

r = requests.get("https://leaf-asrlm.in/api/districts")
for d in r.json()['districts']:
    print(f"{d['name']}: {d['block_count']} blocks")

Get District Boundaries

Returns district boundary polygons as GeoJSON for map overlay display. These are the dashed outlines shown on the main map.

GET /api/districts/geojson

Response

A GeoJSON FeatureCollection of district boundary polygons (structure depends on the source boundary file).

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "dtname": "Tinsukia",
        "stname": "Assam"
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [[[95.3, 27.5]]]
      }
    }
  ]
}

Errors

Code Description
404 District boundaries GeoJSON file not available — returns {"error": "District boundaries not available"}
500 Server error — returns {"error": "<message>"}

Example

curl https://leaf-asrlm.in/api/districts/geojson
import requests
import geopandas as gpd

r = requests.get("https://leaf-asrlm.in/api/districts/geojson")
gdf = gpd.GeoDataFrame.from_features(r.json()['features'])
print(f"Districts: {len(gdf)}")
const r = await fetch('/api/districts/geojson');
const geojson = await r.json();

// Add as dashed overlay on Leaflet map
L.geoJSON(geojson, {
  style: { fillColor: 'transparent', color: '#28537D', dashArray: '6,4' },
  interactive: false
}).addTo(map);

Get Protected Areas

Returns Protected Areas of India (national parks, wildlife sanctuaries, etc.) as a GeoJSON FeatureCollection for map overlay display.

GET /api/protected-areas/geojson

Response

A GeoJSON FeatureCollection of protected-area polygons.

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": { "name": "Dibru-Saikhowa National Park" },
      "geometry": { "type": "Polygon", "coordinates": [[[95.2, 27.6]]] }
    }
  ]
}

Errors

Code Description
404 Protected areas data not available — returns {"error": "Protected areas data not available"}
500 Server error — returns {"error": "<message>"}

Example

curl https://leaf-asrlm.in/api/protected-areas/geojson
const r = await fetch('/api/protected-areas/geojson');
const geojson = await r.json();

L.geoJSON(geojson, {
  style: { color: '#2E7D32', weight: 1, fillOpacity: 0.15 },
  interactive: false
}).addTo(map);

Get Blocks in a District

Returns all blocks belonging to a specific district, sorted alphabetically by block name.

GET /api/districts/{district}/blocks

Parameters

Parameter In Type Required Description
district path string Yes District name, matched exactly against Dist_Name (e.g. "TINSUKIA")

Response

{
  "district": "TINSUKIA",
  "blocks": [
    { "name": "GUIJAN", "district": "TINSUKIA" },
    { "name": "HAPJAN", "district": "TINSUKIA" },
    { "name": "ITAKHULI", "district": "TINSUKIA" }
  ]
}
Field Type Description
district string The requested district name (echoed back)
blocks array Blocks in the district, sorted by name
blocks[].name string Block name
blocks[].district string District name (echoed for each block)

Errors

Code Description
404 District not found — returns {"error": "District \"<name>\" not found"}
500 Server error — returns {"error": "<message>"}

Example

curl https://leaf-asrlm.in/api/districts/TINSUKIA/blocks
import requests

r = requests.get("https://leaf-asrlm.in/api/districts/TINSUKIA/blocks")
data = r.json()
print(f"{data['district']}: {len(data['blocks'])} blocks")
for block in data['blocks']:
    print(f"  - {block['name']}")