Skip to main content

Geo Grid

Enrich Elastic Compatible

Synopsis

Transforms geo-grid definitions (geohash, geotile) into standard geometric shapes (bounding boxes or polygons) for spatial indexing and operations.

Schema

geo_grid:
- field: <ident>
- tile_type: <enum>
- children_field: <ident>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- non_children_field: <ident>
- on_failure: <processor[]>
- on_success: <processor[]>
- parent_field: <ident>
- precision_field: <ident>
- tag: <string>
- target_field: <ident>
- target_format: <enum>

Configuration

FieldRequiredDefaultDescription
fieldY-Field containing the geo-grid cell identifier
tile_typeY-Grid system type: geohash or geotile
children_fieldN-Store child cell identifiers in this field
descriptionN-Documentation note
ifN-Conditional expression
ignore_failureNfalseSkip errors in processing
ignore_missingNfalseSkip if input field is missing
non_children_fieldN-Store intersecting non-child cells here
on_failureN-Error handling processors
on_successN-Success handling processors
parent_fieldN-Store parent cell identifier here
precision_fieldN-Store zoom level/precision here
tagN-Identifier for logging
target_fieldNfieldOutput field for the shape
target_formatNGeoJSONOutput format: WKT or GeoJSON

Details

The processor converts string-based grid cell identifiers into actual geometric shapes that can be used for spatial operations, e.g.

  • a geohash such as "sn4ph" becomes a polygon with precise coordinates
  • a geotile such as "4/8/5" becomes an envelope with defined boundaries

This transformation enables spatial indexing of grid cells, geometric operations (intersection, containment, etc.), visual representation of grid cells, and integration with geo-shape-capable systems.

note

The processor handles different precision levels for both geohash and geotile formats automatically, adjusting the output shape as necessary.

warning

Geohash cells that contain poles cannot be converted to polygons due to coordinate system limitations.

Formats

GeoJSON

For geohash cells, outputs a GeoJSON Polygon:

{
"type": "Polygon",
"coordinates": [
[
[lon1, lat1],
[lon2, lat2],
[lon3, lat3],
[lon4, lat4],
[lon1, lat1] // Closing point
]
]
}

For geotile cells, outputs a GeoJSON Envelope:

{
"type": "Envelope",
"coordinates": [
[minLon, maxLat], // Top-left
[maxLon, minLat] // Bottom-right
]
}

WKT

For geohash cells, outputs a WKT POLYGON:

POLYGON((lon1 lat1, lon2 lat2, lon3 lat3, lon4 lat4, lon1 lat1))

For geotile cells, outputs a WKT ENVELOPE:

ENVELOPE(minLon, maxLon, maxLat, minLat)

Examples

Basic

Converting a geohash to a polygon...

{
"geocell": "sn4ph"
}
geo_grid:
- field: geocell
- tile_type: geohash
- target_field: geoshape

creates a GeoJSON polygon:

{
"geocell": "sn4ph",
"geoshape": {
"type": "Polygon",
"coordinates": [
[
[2.98828125, 34.98046875],
[3.0322265625, 34.98046875],
[3.0322265625, 35.0244140625],
[2.98828125, 35.0244140625],
[2.98828125, 34.98046875]
]
]
}
}

Geotile to WKT

Converting a geotile to WKT...

{
"tile": "4/8/5"
}
geo_grid:
- field: tile
- tile_type: geotile
- target_field: shape
- target_format: wkt

produces a WKT envelope:

{
"tile": "4/8/5",
"shape": "ENVELOPE(0.0, 22.5, 55.77657301866769, 40.97989806962013)"
}

Conditionals

Processing based on a specific state...

{
"geocell": "4/8/5",
"process": true
}
geo_grid:
- field: geocell
- tile_type: geotile
- if: "ctx.process == true"
- target_field: shape

transforms the shape only conditionally:

{
"geocell": "4/8/5",
"process": true,
"shape": {
"type": "Envelope",
"coordinates": [
[0.0, 55.77657301866769],
[22.5, 40.97989806962013]
]
}
}

Error Handling

Handling invalid grid cell values...

{
"geocell": "invalid_value"
}
geo_grid:
- field: geocell
- tile_type: geohash
- ignore_failure: true
- on_failure:
- set:
- field: error
- value: "Invalid geohash"

continues the execution:

{
"geocell": "invalid_value",
"error": "Invalid geohash"
}