A tool that prints the S2 cell for a given coordinate, prints cell info, as well as generates KML visualizations of cell parents and boundaries.
$ go get github.com/dsoprea/go-s2
The following commands are obviously run from "${GOPATH}/src/github.com/dsoprea/go-s2".
Just encode the location into an S2 cell token:
$ go run main.go cell --latitude 42.533333 --longitude -83.146389
883b2d2febf80c13
Encode, but print in the binary representation:
$ go run main.go cell --latitude 42.331389 --longitude -83.045833 --to-binary
1000100000111011001011010010111111101011111110000000110000010011
Print as a specific level (not as the default level-30 leaf cell):
$ go run main.go cell --latitude 42.331389 --longitude -83.045833 --to-binary --level 28
1000100000111011001011010010111111101011111110000000110000010000
Print the parent hierarchy (all levels, from leaf and downwards but excluding the face):
$ go run main.go parents --cell-token 883b2d2febf80c13
30: 883b2d2febf80c13 1000100000111011001011010010111111101011111110000000110000010011 (42.3313890270, -83.0458329624)
29: 883b2d2febf80c14 1000100000111011001011010010111111101011111110000000110000010100 (42.3313890619, -83.0458329214)
28: 883b2d2febf80c1 1000100000111011001011010010111111101011111110000000110000010000 (42.3313889822, -83.0458328395)
27: 883b2d2febf80c4 1000100000111011001011010010111111101011111110000000110001000000 (42.3313891417, -83.0458330034)
26: 883b2d2febf80d 1000100000111011001011010010111111101011111110000000110100000000 (42.3313894606, -83.0458333311)
25: 883b2d2febf80c 1000100000111011001011010010111111101011111110000000110000000000 (42.3313888227, -83.0458326756)
24: 883b2d2febf81 1000100000111011001011010010111111101011111110000001000000000000 (42.3313899394, -83.0458313647)
23: 883b2d2febf84 1000100000111011001011010010111111101011111110000100000000000000 (42.3313924914, -83.0458339866)
22: 883b2d2febf9 1000100000111011001011010010111111101011111110010000000000000000 (42.3313975952, -83.0458392303)
21: 883b2d2febfc 1000100000111011001011010010111111101011111111000000000000000000 (42.3314078030, -83.0458497178)
20: 883b2d2febf 1000100000111011001011010010111111101011111100000000000000000000 (42.3314256712, -83.0458287428)
19: 883b2d2febc 1000100000111011001011010010111111101011110000000000000000000000 (42.3314614075, -83.0457867930)
18: 883b2d2feb 1000100000111011001011010010111111101011000000000000000000000000 (42.3315328802, -83.0457028932)
17: 883b2d2fec 1000100000111011001011010010111111101100000000000000000000000000 (42.3313899348, -83.0458706927)
16: 883b2d2ff 1000100000111011001011010010111111110000000000000000000000000000 (42.3311040418, -83.0462062903)
15: 883b2d2fc 1000100000111011001011010010111111000000000000000000000000000000 (42.3316758248, -83.0455350934)
14: 883b2d2f 1000100000111011001011010010111100000000000000000000000000000000 (42.3328193560, -83.0441926790)
13: 883b2d2c 1000100000111011001011010010110000000000000000000000000000000000 (42.3351062786, -83.0415077682)
12: 883b2d3 1000100000111011001011010011000000000000000000000000000000000000 (42.3305322470, -83.0468774803)
11: 883b2d4 1000100000111011001011010100000000000000000000000000000000000000 (42.3213819469, -83.0576155902)
10: 883b2d 1000100000111011001011010000000000000000000000000000000000000000 (42.3004691734, -83.0361376180)
9: 883b2c 1000100000111011001011000000000000000000000000000000000000000000 (42.2586088499, -82.9931606652)
8: 883b3 1000100000111011001100000000000000000000000000000000000000000000 (42.1852657331, -83.0790865486)
7: 883b4 1000100000111011010000000000000000000000000000000000000000000000 (42.0380079749, -83.2506007353)
6: 883b 1000100000111011000000000000000000000000000000000000000000000000 (41.7009333540, -82.9071229569)
5: 883c 1000100000111100000000000000000000000000000000000000000000000000 (41.1029130410, -83.5922642307)
4: 883 1000100000110000000000000000000000000000000000000000000000000000 (42.2867653582, -82.2148598567)
3: 884 1000100001000000000000000000000000000000000000000000000000000000 (39.8711280030, -84.9401311537)
2: 89 1000100100000000000000000000000000000000000000000000000000000000 (34.0478629694, -79.3803447238)
1: 8c 1000110000000000000000000000000000000000000000000000000000000000 (21.0375110254, -67.3801350520)
Generate KML showing all parents along with cell bouundaries (at or less than level 15):
$ go run main.go parents_kml --cell-token 883b2d2febf80c13
When the KML is opened in Google Earth, it will render something like: