11# closecity (Python SDK)
22
33Python client for the Close travel-time API (https://api.close.city ). httpx-based,
4- returns ` geopandas ` by default. Sphinx + Furo docs deploy to GitHub Pages; PyPI (via
5- OIDC trusted publishing) is the eventual target. Public repo:
4+ returns tabular data by default (a ` geopandas.GeoDataFrame ` where geometry applies, a
5+ plain ` pandas.DataFrame ` otherwise). Sphinx + Furo docs deploy to GitHub Pages; PyPI
6+ (via OIDC trusted publishing) is the eventual target. Public repo:
67` henryspatialanalysis/closecity-python ` . The R sibling is
78` henryspatialanalysis/closecity-r ` -- keep the two SDKs behaviourally in step.
89
@@ -15,19 +16,31 @@ OIDC trusted publishing) is the eventual target. Public repo:
1516- ** Attribution:** copyright and funder is "Henry Spatial Analysis", never "Close".
1617 Author ` Nathaniel Henry <nat@henryspatialanalysis.com> ` .
1718- ** Code style:** line length 90, spaces around ` = ` even inside calls (Nat overrides
18- linters on this). ` ruff ` clean.
19- - ** API shape:** ` Client ` with one method per route; ` Reply ` / ` Paginator ` . Feature
20- methods convert to geopandas via ` spatial.py ` (` to_geopandas() ` is also public).
21- - ** Spatial by default:** feature methods (POIs, catchments, areal blocks, isochrones)
22- return a ` GeoDataFrame ` . ` Client(spatial=True) ` is the default; ` spatial=False ` (on
23- the client or per call) returns the raw ` Reply ` . Catalog/places/summaries stay raw.
24- - ** Dependencies:** ` geopandas>=0.14 ` is a hard dependency. ` pygris ` is the ` [tiger] `
25- extra, used only to fetch block boundaries for the GEOID-only block routes
26- (` fetch=True ` ). Keep the runtime footprint minimal otherwise.
19+ linters on this: ` E251 ` /` E252 ` are ignored). ` ruff check ` clean with
20+ ` select = ["E","F","W","I","N","UP","B","C4","SIM"] ` . ** Never run ` ruff format ` ** --
21+ it strips the kwarg ` = ` spacing; lint only.
22+ - ** API shape:** ` Client ` with one method per route; ` Reply ` / ` Paginator ` . Routes
23+ with geometry convert via ` spatial.py ` (` to_geopandas() ` ), everything else via
24+ ` tabular.py ` (` to_pandas() ` ); both are public. The ` Client._deliver() ` chokepoint
25+ routes by the resolved output mode.
26+ - ** Output modes (` output ` , default ` "spatial" ` ):** ` "spatial" ` returns a
27+ ` GeoDataFrame ` where geometry applies (points, isochrone and block polygons) and a
28+ plain ` DataFrame ` for catalog and summary routes; ` "tabular" ` returns a plain
29+ ` DataFrame ` everywhere and never downloads block boundaries; ` "raw" ` returns the
30+ ` Reply ` / ` Paginator ` . Set it on the client (` close.output = "raw" ` ) or per call
31+ (` ..., output = "tabular" ` ). ` health ` /` last_updated ` /` isochrone_meta ` are always raw;
32+ a 304 is always raw. Metering + envelope ride on ` df.attrs ` . Keep the R SDK's
33+ identical ` output ` vocabulary in step.
34+ - ** Dependencies:** ` pandas>=1.5 ` and ` geopandas>=0.14 ` are hard dependencies. ` pygris `
35+ is the ` [tiger] ` extra, used only to fetch block boundaries for the GEOID-only block
36+ routes in ` spatial ` mode. Keep the runtime footprint minimal otherwise.
2737- ** Tutorials (notebooks):** dead-simple and linear, ** no helper functions** . Pull
2838 destination-type ids from the ** free catalog** (` client.destination_types() ` ), never
29- hardcode numeric codes. Draw a ** map at each stage** . ** No token-cost talk.** After a
30- placeholder key, inline ` # use your own key here ` .
39+ hardcode numeric codes. Draw a ** map at each stage** . State the tutorial's ** measured
40+ token usage** in one italic line near the top ("Running this tutorial uses about N
41+ tokens."); keep every tutorial ** under 5,000 tokens** and do not publish a cheaper
42+ variant on the same page. No other token-cost talk in the body except the dedicated
43+ ` docs/token_use.md ` page. After a placeholder key, inline ` # use your own key here ` .
3144- ** Example cities:** Somerville MA (home search), Richmond VA (amenity basket),
3245 Providence RI (competitor walksheds). ** No Seattle anywhere.**
3346- ** Docs execute live** at build time (see below), guarded on ` CLOSECITY_KEY ` so a
0 commit comments