Terra by Tec Solution KSA
At a glance Documentation
Terra System
Saudi National Spatial Index · v1.0
SANSRS Compliant KSA-GRF17 Native Apache 2.0 Open Source
Developed by Tec Solution KSA

The National
Hexagonal
Spatial Index
for Saudi Arabia

Terra assigns every location in the Kingdom — from a doorstep in Riyadh to an oil field in the Empty Quarter — a precise, permanent hexagonal address. A single open system connecting land, government, industry, logistics, and every citizen service on one universal spatial grid.

KSA-GRF17 · EPSG:9333 SANSRS aligned GEOSA · MOMRA ready Res 8 = exactly 1 hectare 6 language bindings
Terra hexagonal grid — 19-cell cluster
Land
Agriculture
Emergency
Logistics
Energy
Telecom
15
Resolution levels
1 ha
Base cell — Res8
215M+
Cells covering KSA
18 cm
Finest cell — Res 14
What is Terra System?

A spatial grid built for the Kingdom

Terra is an open-source hierarchical geospatial indexing system. It divides Saudi Arabia into a nested grid of regular hexagonal cells, each uniquely identified by a compact numeric code. Think of it as a universal address system for space itself — one that works in deserts, cities, at sea, underground, and in the air.

Unlike a street address, which is tied to infrastructure that may not exist, a Terra cell exists everywhere — even in uninhabited desert, remote coastline, or mid-construction megaprojects. Unlike GPS coordinates, which are raw numbers with no context, a Terra cell carries hierarchy: every cell knows its parent region, its neighbouring cells, and its children.

Terra cells are hexagonal because hexagons tile a plane with equal-distance neighbours — each of the six adjacent cells is the same distance from the centre. This makes spatial analysis simpler, more consistent, and more accurate than square grids, where corner neighbours are farther away than edge neighbours.

Every location in Saudi Arabia has a Terra address. From the top of Jabal Sawda to the deepest point of the Red Sea — every point falls inside exactly one 1-hectare cell.
Terra resolution hierarchy — Res 5, Res 7, Res 8 Res 5 · 343 ha · District Res 7 · 7 ha · Block Res 8 1 ha Base cell (national standard)
Hexagonal cells
Regular hexagons tile the plane with equal-distance neighbours. All 6 adjacent cells are the same spatial distance from the centre — no bias toward cardinal directions.
Hierarchical by design
Each cell belongs to a parent at a coarser resolution. Every Res 8 (1 ha) cell has a Res 7 parent (7 ha), a Res 6 grandparent (49 ha), and so on — up to national scale.
Compact, unique ID
Every cell is a 64-bit integer — a single number encodes its position and resolution. Compact enough to store in any database column or transmit in an API response.
Resolution levels

From 0.09 m² to 57,000 km² — 15 levels

Every Terra cell sits at one of 15 resolution levels. Moving one level coarser multiplies the cell area by 7 (aperture-7 hierarchy). Resolution 8 — the 1-hectare base cell — is the national standard anchor.

Res Name Cell edge Cell area Cells in KSA Primary use
Why Saudi Arabia needs Terra

The problem Terra solves

Saudi Arabia has undergone rapid spatial development — yet the foundational data infrastructure connecting government ministries, private enterprises, and citizens remains fragmented. Terra addresses four core problems.

01
Fragmented spatial data
Different government agencies have used different coordinate reference frames for decades — GDMS, MTRF-2000, ARAMCO WGS84, and Ain Al Abd. Data from separate sources may be off by up to 93 metres, making cross-agency integration unreliable or impossible.
Terra uses KSA-GRF17 (SANSRS) as its native datum. All legacy frames are automatically transformed. One grid, one reference, one truth.
02
Addressing gaps
Large portions of Saudi Arabia — deserts, industrial zones, NEOM construction areas, rural farmland — have no street address. Emergency services, logistics operators, and government agencies cannot uniquely identify these locations without GPS coordinates, which carry no context or hierarchy.
Every point in the Kingdom, regardless of infrastructure, falls inside exactly one Terra cell with a stable, short, human-readable code — permanently.
03
Spatial data integration is expensive
Joining data from land registry, logistics operations, environmental sensors, and healthcare facilities requires complex, error-prone spatial joins. These joins are slow at scale, require specialist GIS software, and break whenever reference frames differ between sources.
A Terra cell index is a plain integer. Joining datasets becomes a standard database JOIN — no geometry engine required, no projection alignment needed.
04
No national scale-invariant grid
Analysis that spans multiple spatial scales — from individual parcels to national statistics — requires separate data at each scale. There is no consistent hierarchy connecting a 1-ha farm plot to its governorate, its region, and the national picture.
Terra's aperture-7 hierarchy directly connects Res 8 (1 ha) cells to every coarser level via a single integer operation. No resampling, no re-projection.
Legal foundation: Council of Ministers Decision No.90 mandates that all surveys and geospatial activities in the Kingdom are linked to SANSRS (KSA-GRF17). Terra is the first and only spatial indexing system designed from the ground up to be SANSRS-native.
Who should use Terra?

Built for everyone who works with location in Saudi Arabia

Terra is designed to serve a wide range of audiences — from government ministries needing a compliant national standard, to mobile developers building location-aware applications.

Government Ministries & Agencies
  • GEOSA — national land registry & SDI
  • MOMRA — urban planning & municipalities
  • Civil Defence — emergency dispatch
  • MEWA — agriculture & environment
  • Saudi Post — national addressing
  • Ministry of Health — coverage planning
  • Ministry of Transport — road & rail
Private Sector Organisations
  • Logistics & delivery companies (Naqel, Aramex)
  • Telecommunications (STC, Mobily, Zain)
  • Energy & oil (Saudi Aramco, SABIC)
  • Real estate developers
  • Agriculture & precision farming
  • Retail & supply chain operations
Developers & Data Teams
  • GIS analysts — QGIS, ArcGIS workflows
  • Backend developers — location services
  • Data scientists — spatial ML & analytics
  • Platform engineers — PostGIS, DuckDB
  • Mobile developers — React Native, iOS, Android
  • Data engineers — ETL / spatial pipelines
Field & Survey Professionals
  • GNSS surveyors (KSA-CORS users)
  • Cadastral inspectors
  • Environmental field teams
  • Emergency responders
  • Construction & site managers
  • Drone survey operators
Impact across the Kingdom

One grid — every sector

Terra provides the common spatial language that connects each of these sectors to one another. A logistics zone, an agriculture permit, an emergency dispatch area, and an environmental monitoring point all reference the same underlying grid.

For developers
Built for the way engineers work.
A C core with six language bindings and a CLI. Indexing, traversal and hierarchy are pure arithmetic on the cell identifier — no spatial index, no geometry tables, no network call.
Python
pip install terra-sa
# Geocode KSA-GRF17 coordinates cell = terra.latlon_to_cell(24.6877, 46.7219, res=8) # → "t108858dc825ffff8" parent = terra.cell_to_parent(cell, res=6) ring = terra.grid_ring(cell, k=1)
JavaScript / Node
npm install terra-sa
// terra-js — WebAssembly, works in browser import * as terra from 'terra-sa' const cell = terra.latLngToCell(24.6877, 46.7219, 8) const bnd = terra.cellToBoundary(cell) const disk = terra.gridDisk(cell, 2)
PostgreSQL / PostGIS
CREATE EXTENSION terra;
-- Geocode in SQL SELECT terra_latlon_to_cell(24.6877, 46.7219, 8); -- Aggregate deliveries by Res 6 zone SELECT terra_cell_to_parent(cell, 6) AS zone, COUNT(*) AS orders FROM deliveries GROUP BY 1;
Command line (terra-cli)
brew install terra-sa
# Geocode from shell terra latlon-to-cell 24.6877 46.7219 -r 8 # → "t108858dc825ffff8" # Polyfill a GeoJSON polygon terra polyfill riyadh.geojson -r 8 | terra to-geojson
Also available: terrasar  (R) terra-go  (Go) terra  (DuckDB extension) terra  (PostgreSQL extension)
Machine learning & AI

Spatial data that is already in the shape AI needs

Most spatial data cannot be fed to a model without weeks of preparation. Boundaries disagree, areas differ, projections conflict, and every join is a geometric operation. Indexed to Terra, location becomes an integer key and the grid becomes a table — one row per cell, one column per dataset. The preparation step largely disappears.

01
A fixed feature table, not a pile of shapes
Models consume rectangular tables. Parcels, districts, catchments and service areas are irregular polygons of differing size that no model accepts directly.
Every cell is a row. Every indexed dataset is a column. Rainfall, elevation, land cover, footfall and consumption line up on the same key with no resampling and no overlay.
02
Equal area removes a hidden bias
On grids whose cells change size with latitude, a raw count is not comparable between cells. Models trained on such counts learn the geometry of the grid as well as the signal.
Every Terra cell at a resolution covers identical ground. A count is a density. No area weighting, no latitude correction, no normalisation step to get wrong.
03
Uniform adjacency suits spatial models
Square grids have neighbours at two different distances — four across edges, four across corners — so convolution and diffusion need correction factors.
Six neighbours, all equidistant, at every resolution with no exceptions. Convolutional and graph neural networks operate on the grid directly; message passing needs no weighting.
04
Multi-scale features without resampling
Capturing both local detail and regional context normally means resampling every layer at every scale, and reconciling the results.
A coarser cell is arithmetic on the identifier. Res 8, 7 and 6 features come from one indexed dataset — a feature pyramid produced by truncation rather than by processing.
05
Honest validation, and no spatial leakage
Random train and test splits put neighbouring observations on both sides. Accuracy looks excellent in testing and collapses in the field.
Split on a coarse parent cell and every fine cell in a block stays on one side. Spatial cross-validation becomes a GROUP BY, and reported accuracy means something.
06
Reproducible, shareable, privacy-aware
Training sets built from coordinates are hard to reproduce and harder to share, because the coordinates themselves are often the sensitive part.
A cell identifier is permanent, so a dataset can be reconstructed exactly. Publishing at a coarser resolution protects individuals while preserving spatial structure — the same pipeline, one parameter changed.
Feature engineering becomes a join
Assembling a training set from four unrelated sources — no spatial predicate, no overlay, no resampling.
-- One row per hectare, one column per source SELECT c.terra_cell, e.mean AS elevation, v.mean AS ndvi, l.majority AS land_cover, COUNT(p.id) AS incidents FROM terra_cells c LEFT JOIN elevation_hex e USING (terra_cell) LEFT JOIN ndvi_hex v USING (terra_cell) LEFT JOIN landcover_hex l USING (terra_cell) LEFT JOIN incidents p USING (terra_cell) GROUP BY c.terra_cell, e.mean, v.mean, l.majority; -- Regional context for the same cells, by truncation SELECT terra_cell, terra_cell_to_parent(terra_cell, 6) AS context_cell FROM terra_cells; -- Spatial cross-validation: whole blocks, never neighbours SELECT terra_cell_to_parent(terra_cell, 4) AS fold FROM training_set;
Two string representations

Terra Index String and Terra Grid Code

Every Terra cell has two human-readable string representations. The Terra Index String (TIS) is the low-level form used by code and databases. The Terra Grid Code (TGC) is the human-readable form — compact, resolution-explicit, with no administrative boundary reference. Both strings represent the same cell and convert between each other with pure arithmetic. No lookup table, no network call needed.

Terra Index String — TIS
Developer · API · database · PostGIS · Python · JS
t108858dc825ffff8
t
Terra prefix
16 hex
64-bit integer
17 chars
Always fixed length
Always 17 characters at every resolution. Resolution encoded in bit field 55–52. Sortable, fixed-width, and safe to use as a primary key. The native form for PostGIS, DuckDB, language libraries, and all API responses.
Terra Grid Code — TGC
Citizen · field worker · map · sign · dispatch
T08-11CDS0J0
T
Terra
08
Resolution (1 ha)
11CDS0J
Position — Base32
0
Check character
Resolution-explicit prefix. Position in Base32 — 32 unambiguous characters (excludes I, L, O, U). No region or admin boundary reference. A cell at the border of two regions gets one unique code based purely on its geometric position. Length scales with resolution.
The same cell in both forms, at every resolution
Resolution Terra Index String (TIS) TIS length Terra Grid Code (TGC) TGC length Cells at this resolution
Res 0t10085ffffffffff817T00-22T7~37 national tiles
Res 2t102858fffffffff817T02-45HG8~1,800 cells
Res 4t104858ddfffffff817T04-8B3E39~89,000 cells
Res 6t106858dc87fffff817T06-GP6WG010~4.4M cells
Res 8 ★t108858dc825ffff817T08-11CDS0J012~215M cells (1 ha)
Res 10t10a858dc82427ff817T10-22RVJ144B13~10.5B cells
Res 12t10c858dc824215f817T12-45HQ4288A314~516B cells
Res 14t10e858dc8242152017T14-8B3E84GGN4515~25T cells
Reading the table: every row is the same location in Riyadh, indexed at a different resolution. The TIS is always 17 characters — fixed width, sortable, ideal as a database key. The TGC grows with resolution, from 7 characters at Res 0 to 15 at Res 14, because a finer cell needs more information to identify it. Both forms describe the identical cell and convert between each other by arithmetic. The final TGC character is a check digit: it catches 100% of single-character substitutions and 99.7% of adjacent transpositions, so a mistyped code is rejected rather than silently resolving to the wrong hectare.
Voice-ready
The TGC at Res 8 is 10 characters. Easy to read over a radio or phone. Emergency dispatch can communicate a precise location without GPS coordinates. "T-zero-eight, K-four, Q-N, seven-P."
Works offline
TGC encodes geometric position only. No lookup server needed to decode it. The terra-core library converts TGC ↔ TIS ↔ lat/lng entirely offline on any device.
QR & print ready
Both TIS and TGC fit in a standard QR code. The TGC can be printed on a property deed, delivery label, or field marker. The resolution prefix tells the reader the exact precision level.
SANSRS & KSA-GRF17

Full compliance with the national spatial reference system

SANSRS — the Saudi Arabia National Spatial Reference System — defines the legal coordinate framework for all surveys and geospatial activities in the Kingdom. Terra is natively built on SANSRS components. No conversion layer, no approximation.

EPSG code Name Description Terra usage
9333 KSA-GRF17 geographic 2D Primary horizontal datum — lat/lng on GRS 1980 ellipsoid anchored to ITRF2014 epoch 2017.0 Primary input
9332 KSA-GRF17 geographic 3D Horizontal + ellipsoidal height; used when accepting GNSS observations from KSA-CORS 3D input
9356 – 9360 KSA-GRF17 / UTM zone 36N–40N KSA-GRF17 in projected UTM coordinates — five zones covering Saudi territory Accepted input
9335 KSA-VRF14 height Orthometric height above mean sea level at the Jeddah Tide Gauge (Helmert-Orthometric) Vertical datum
9520 KSA-GRF17 + KSA-VRF14 height Compound CRS combining horizontal GRF17 and vertical VRF14 — the complete 3D SANSRS 3D cell CRS
10776 KSA-GRF17 → KSA-VRF14 (KSA-GEOID21) Geoid model transformation (KSA-GEOID21.gra) — 1.5 cm accuracy. Converts GNSS ellipsoidal height to orthometric height for 3D Terra cells Geoid transform

Legacy datum migration

Terra includes built-in Helmert transformation parameters for all four historical KSA reference frames: GDMS (0.6 m shift), MTRF-2000 (0.6 m), ARAMCO WGS84 (0.8 m), and Ain Al Abd (93 m grid transformation). Organisations migrating to SANSRS can simultaneously re-index their spatial data into Terra.

KSA-CORS integration

The 200+ active KSA-CORS stations operated by GEOSA provide real-time KSA-GRF17 positioning. A field surveyor's GNSS receiver outputs KSA-GRF17 coordinates directly, which feed into Terra without any conversion step. RTK precision to 1–2 cm maps to sub-cell accuracy at Res 9 (23 m cells).