Skip to content
oslew
Get a free key

Use case

Enriching coordinates with location data

To enrich coordinates with location data, send each point to a single call that asks every loaded layer about it, keep the columns you need, and store each column under the licence of the layer it came from. With oslew that call is /v1/here: one request per row returns the municipality, the ISO region code, the IANA time zone, the height of the terrain and the nearest road, and a layer with nothing to say leaves its column empty instead of failing the row.

Last reviewed

Coordinates arrive from everywhere — a sign-up form’s geolocation, a device heartbeat, a delivery scan — and they are almost useless for reporting on their own. Nobody filters a dashboard by latitude. The work is turning each point into the codes and names people group by, and doing it in a way that survives a million rows, a missing layer and a licence review.

The shape of the job

The input is a table with an id, a latitude, a longitude and usually the time of the event. The output adds a handful of columns:

Column Taken from Notes
country The country division Two-letter ISO code
region_code The region division ISO 3166-2, prefix included
municipality, municipality_id The first of county, localadmin, locality Group by the id
tzid The timezone field IANA zone id
local_time tzid plus the event time Computed in your own runtime
elevation_m The raster entry named elevation Rounded to the metre
road_class, road_m The road field Nearest road on the driving network

Every column comes from one response per row, and every one of them can be empty.

Step one: a single row, on its own

Send the first coordinate before starting a pool. /v1/here belongs to the Platform product, so a key on a plan without it is refused with a 403 that names the plan that would answer — better to learn that once than ten thousand times. The same response carries RateLimit-Limit, the sustained rate the key was sold, which is what the rest of the run should be paced to.

Step two: pace the rest

A pacer that hands out evenly spaced start times, shared by a few concurrent workers, keeps the run at the plan’s rate without spending the burst in the first second and then stalling on HTTP 429. On the Platform plan that rate is 20 requests a second sustained, burst 100. Divide your row count by the sustained figure to know how long a run will take; the burst shortens only the first moment of it. A retry helper that honours Retry-After covers whatever 429 responses remain, and because the plan is a rate with no monthly quota, a rerun of a failed batch costs time, not money.

Step three: pick the fields

Country and region come straight from the country and region entries of the chain. The region code already carries its country prefix, so it joins cleanly to any table keyed by ISO 3166-2.

Municipality needs a rule. Nations divide themselves differently, and Overture maps their tiers onto a common set of subtypes: in Mexico City the borough arrives as county, elsewhere the equivalent may be a localadmin or a locality. Taking the first of those three is a reasonable default. Look at a sample of rows for each country before trusting it, and override the order per country if the sample shows the wrong level.

Local time is yours to compute. The answer gives the zone id without an offset, so convert the event’s unix time with your runtime’s own time zone database. A zone newer than that database cannot be converted; leave the cell empty rather than guessing.

Elevation is the value of the raster entry whose layer is elevation, a surface height from Copernicus GLO-30. The nearest road is a class and a distance on the driving network. A point several hundred metres from it is probably open land, and that road is not its address.

Step four: analytics by municipality

Group by the municipality’s id, not its name. Names repeat — a city and its region can share one — and the id is what makes two rows the same place. Keep the name alongside for display only.

Rows near a division’s edge deserve a second look. Each division in the chain says whether it was decided with the point’s cell wholly inside it or by testing the polygon near an edge. If your coordinates are themselves uncertain — a phone’s location, a geocoded address with a wide precision estimate — count edge cases separately, or at least be ready to explain why a customer three streets from a municipal line was attributed to the neighbouring one.

Step five: store each column by its licence

One response mixes data under different licences, and a warehouse that ignores that difference ends up with a table it cannot share. The boundaries API covers the divisions’ provenance in detail; for this job the columns fall into three groups:

  • Share-alike: country, region and municipality come from divisions Overture publishes under ODbL-1.0, the time zone from data licensed ODbL-1.0, and road class and distance from ODbL-1.0. Keeping them for internal analysis is straightforward, with attribution; publishing a table derived from them brings share-alike obligations.
  • Attribution: elevation carries the Copernicus DEM licence, which asks for its attribution wherever the heights are shown.
  • Permissive, if you add them: the nearest addresses and places in the same response are Overture data under permissive licences, and may be stored and shared without share-alike.

Do not sort the admin columns by the code the API writes. On division entries provenance.license currently reads CDLA-Permissive-2.0, which disagrees with Overture’s published ODbL, and the publisher’s licence is the one that applies.

A practical layout keeps your own fields and any address or place columns in the main table, and the ODbL columns — the admin codes, the time zone and the road — in a side table joined by row id, so the main table can be exported without dragging share-alike data along. /v1/here does not attach provenance to its road or raster values; fetch the licence and release once from /v1/snap and /v1/raster and record them with the run. The licensing page states every layer’s terms.

When one column is enough

/v1/here does all of its work on every call, which is wasteful when a job needs a single field:

  • Only the time zone and its offset at an instant: the time zone API, on the Address product.
  • Only the administrative chain: /v1/admin, or reverse geocoding, which returns the same chain beside the nearest addresses on the Address product.
  • Only heights, or a profile along a line: the elevation API.

Each of those is one request per row too, and each is quicker than the combined call.

Refreshing the columns

Divisions, zones, roads and terrain change only with a new data release, so an enriched table stays valid until then. Record provenance.release from the divisions with each run and re-enrich when it moves. Weather readings from the same call are the exception: they change within hours, and should be fetched fresh rather than stored beside static columns.

Bottom line

One paced /v1/here request per row fills municipality, region code, time zone, elevation and nearest road. Decide the municipality rule per country, group by ids, keep the ODbL columns in their own table before anything is exported, and switch to a single-purpose endpoint when you need only one column. The same call is available to agents as the here tool through the MCP server.

Where this workflow falls short

  • An empty municipality or region means the loaded divisions do not cover that point, not that the point lies in no municipality; what can be filled depends on the layers the deployment carries.
  • Which subtype counts as the municipality is set by Overture’s mapping of each nation’s tiers, so a single rule applied across several countries will group some rows at the wrong level.
  • The nearest road is the closest segment of the driving network, which is not necessarily the street a building’s address is on, and a large distance usually means open land.
  • Elevation comes from a surface model: over dense buildings or forest it reads roofs or canopy, so treat small differences between nearby rows as noise.
  • The country, region, municipality, time-zone and road columns are all ODbL. Keeping them internally is fine; publishing a table derived from them brings share-alike obligations.

Questions

Which fields can one request add to a coordinate?

A /v1/here call returns the full administrative chain with ISO country and region codes, the IANA time zone, the nearest addresses and places, the nearest road with its class and distance, every loaded raster value including elevation, the latest nearby station readings and transit stops in range. Most enrichment jobs keep five or six of those.

Can I keep the enriched columns in my data warehouse?

Yes, with the licence in mind per column. Country, region and municipality come from Overture’s divisions, published under ODbL-1.0, and the time zone and road columns are ODbL-1.0 as well: every one of them may be stored, and every one brings share-alike obligations if you publish a database derived from it. Elevation asks for its attribution sentence wherever it is shown.

How do I choose the municipality when countries are divided differently?

Take the first of county, localadmin and locality that the chain contains, then check a sample of points in each country and adjust the order per country where it matters. Group by the division’s id rather than its name, because names repeat across levels and between countries.

What if I only need the time zone?

Ask /v1/timezone instead. It is part of the Address product, so it works on the cheapest paid plan and on Free, and it returns the zone’s offsets at a timestamp as well as its IANA id. /v1/here needs the Platform product and does far more work than a single column requires.

Why do some rows come back with empty columns?

Because /v1/here never fails for a missing layer: a layer that has nothing at the point, or is not loaded at all, contributes an empty field. Points at sea, outside the divisions or elevation data, or far from any road will have gaps. A coordinate that cannot be parsed is the only case refused with an error.

Browse every page →