Appearance
Tag: g
Overview
The g
tag provides location information using a geohash, allowing Nostr events to be associated with specific geographic locations. Geohashing is a public domain geocoding system that encodes geographic coordinates into a short string of letters and digits, with longer strings providing more precise locations.
Specification
Property | Value |
---|---|
Tag Name | g |
Defined in | NIP-52 |
Required for | Optional for calendar events (kind 31922, 31923), pictures (kind 20), and can be used in other kinds where location is relevant |
Format
["g", "<geohash>"]
Usage Description
The g
tag contains a single value parameter: a geohash string representing geographical coordinates. Geohashes encode both latitude and longitude into a single string, with each additional character in the string providing greater precision.
- Geohash precision depends on the string length:
- 1 character: ~5,000km × 5,000km region
- 2 characters: ~1,250km × 625km region
- 3 characters: ~156km × 156km region
- 4 characters: ~39km × 20km region
- 5 characters: ~5km × 5km region
- 6 characters: ~1.2km × 0.6km region
- 7 characters: ~153m × 153m region
- 8 characters: ~38m × 19m region
- 9 characters: ~5m × 5m region
Clients should choose an appropriate precision level based on the use case, considering privacy implications of sharing exact locations.
Examples
Basic Example
For a calendar event in San Francisco (approximate city center):
json
["g", "9q8yy"]
Extended Example
For a calendar event specifying a more precise location in Central Park, New York:
json
["g", "dr5ru7n"]
Client Behavior
Clients that support the g
tag should:
- Generate geohashes for events when users wish to associate them with geographic locations
- Parse geohashes in received events to display associated locations on maps or in text form
- Implement appropriate UI for entering and viewing location information
- Consider privacy implications when displaying or requesting precise locations
- Support geospatial searches for events that contain geohash tags
Relay Behavior
Relays could:
- Index events by geohash to support geographic queries
- Support proximity-based searches for events near a specified location
- Respect the precision of geohashes as provided, without attempting to increase precision
References
- NIP-52: Calendar Events
- Geohash on Wikipedia
- Geohash Explorer - Tool for exploring and visualizing geohashes
Related Tags
- t - Hashtags, which can complement geographic data for location-based events
Notes
Since geohashes encode both latitude and longitude into a single string, adjacent locations on the map might not have similar geohash prefixes due to how the encoding works. This should be considered when implementing geospatial searches.
Clients should be careful about displaying precise geohashes for private events or locations as they can reveal sensitive information.
When events represent moving objects or people (like a running event that covers multiple locations), multiple geohashes covering the route can be used, though this is not specifically defined in NIP-52.