unsprawl.geocoding

Lightweight geocoding helpers.

The core resale dataset published by data.gov.sg does not include coordinates. For MRT accessibility scoring we need a (lat, lon) per record.

This module provides a conservative fallback: infer coordinates using a predefined centroid per town.

Notes

  • This is an approximation intended to enable accessibility scoring out-of-the-box.

  • If your dataset has true coordinates (lat/lon), those always take precedence.

Attributes

Functions

ensure_lat_lon_from_town_centroids(df, *[, town_col, ...])

Ensure DataFrame has numeric lat and lon columns.

Module Contents

TOWN_CENTROIDS: Final[dict[str, tuple[float, float]]]
ensure_lat_lon_from_town_centroids(df, *, town_col='town', lat_col='lat', lon_col='lon')[source]

Ensure DataFrame has numeric lat and lon columns.

If lat and lon already exist, they are coerced to numeric and left as-is. If one or both are missing, they are inferred from town using TOWN_CENTROIDS.

Unknown towns will remain NaN.