Skip to content

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

PropertyValue
Tag Nameg
Defined inNIP-52
Required forOptional 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:

  1. Generate geohashes for events when users wish to associate them with geographic locations
  2. Parse geohashes in received events to display associated locations on maps or in text form
  3. Implement appropriate UI for entering and viewing location information
  4. Consider privacy implications when displaying or requesting precise locations
  5. Support geospatial searches for events that contain geohash tags

Relay Behavior

Relays could:

  1. Index events by geohash to support geographic queries
  2. Support proximity-based searches for events near a specified location
  3. Respect the precision of geohashes as provided, without attempting to increase precision

References

  • t - Hashtags, which can complement geographic data for location-based events

Notes

  1. 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.

  2. Clients should be careful about displaying precise geohashes for private events or locations as they can reveal sensitive information.

  3. 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.