> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Geohashing

> Copy-paste examples of geohashing data with SQL

## Enrich a Point-Based Table with Geohashes

Create a geohash for pickup locations in the NYC taxi data set.

<CodeGroup>
  ```sql Lat/Lon-Based Table theme={null}
  CREATE OR REPLACE TABLE example_geospatial.nyctaxi_geohash AS
  (
  	SELECT
  		pickup_latitude,
  		pickup_longitude,
  		STXY_GEOHASH(pickup_longitude, pickup_latitude, 6) AS geohash
  	FROM example_geospatial.nyctaxi_xy
  )
  ```

  ```sql WKT-Based Table theme={null}
  CREATE OR REPLACE TABLE example_geospatial.nyctaxi_geohash AS
  (
  	SELECT
  		pickup_location,
  		ST_GEOHASH(pickup_location, 6) AS geohash
  	FROM example_geospatial.nyctaxi_wkt
  )
  ```
</CodeGroup>

## Create an Aggregated View with WKT Geometries

Use the table created above to generate a geohash grid view with the counts of
pickups within each cell.

```sql Aggregated Pick-Up Counts per Geohash Cell theme={null}
SELECT
	geohash,
	ST_GEOMFROMGEOHASH(geohash) AS geohash_cell,
	COUNT(*) AS total_pickups
FROM example_geospatial.nyctaxi_geohash
GROUP BY geohash
```

The geohash grid output as a class break render:

<img src="https://mintcdn.com/kinetica/47teRgjGtbiLXAyb/content/snippets/geohash/geohash.png?fit=max&auto=format&n=47teRgjGtbiLXAyb&q=85&s=7bfa841344729abe27c2c53967186e49" alt="geohash.png" width="900" height="485" data-path="content/snippets/geohash/geohash.png" />
