PostGIS schema
MapLark stores OpenStreetMap in three geometry tables in schema osm. Use this page to choose type, way_shape, and tags so a query hits the right table and index. You query through HTTP or the SDK. There is no SQL endpoint and no database URL for API keys.
Three tables
Geometry is a single geom column in EPSG:4326. Remaining OSM tags stay in tags JSONB. A few high-traffic keys are also copied onto typed text columns so common filters stay index-friendly.
| Table | What it holds | Typical query |
|---|---|---|
osm.osm_point | Tagged nodes. Always a Point. POIs, peaks, bus stops, benches. | type=node |
osm.osm_line | Linear ways and some relations (routes, boundaries). Roads, paths, rivers, roundabouts. Closed highways stay lines, not polygons. | type=way&way_shape=line |
osm.osm_polygon | Area ways and multipolygon or boundary relations. Buildings, parks, lakes, landuse. Closed ways with area tags land here. | type=way&way_shape=polygon |
How to pick a table
type is the OSM element kind: node, way, or relation. way_shape is the geometry class for ways and relations only. Nodes always go to osm_point.
- Nodes (POIs, peaks, benches):
type=node. - Roads, paths, rivers:
type=wayortype=relation, andway_shape=line. - Buildings, parks, landuse:
way_shape=polygon. - POIs that may be a node or a building polygon:
type=node,way&way_shape=polygon. - Unknown mix: omit both. The API unions all three tables.
Reference mapping:
| Params | Reads |
|---|---|
type=node | osm.osm_point |
type=way&way_shape=line or type=relation&way_shape=line | osm.osm_line |
type=way&way_shape=polygon | osm.osm_polygon |
type=node,way&way_shape=polygon | points plus polygons |
| omit both | points, lines, and polygons |
limit applies per table or union arm. Omitting way_shape for ways can return up to two pages of that size (line plus polygon). Set way_shape when the geometry class is known. Parameter reference: OSM Features API.
Columns
Every table has osm_id, osm_type (N / W / R), tags JSONB, and geom. GeoJSON id looks like way/123. Properties keep the full tag map. Import drops noisy prefixes such as source, tiger, and created_by.
| Table | Extra columns | Typed tag columns (common filters) |
|---|---|---|
osm_point | place, natural, aeroway, amenity, shop, tourism, public_transport, opening_hours | |
osm_line | length_m | highway, railway, waterway, aerialway, boundary, admin_level, tunnel, bridge, oneway, layer, ref |
osm_polygon | area_m2 | building, landuse, natural, leisure, amenity, shop, aeroway, waterway, water, boundary, admin_level, opening_hours |
- Line size filters:
min_length_m,max_length_m. - Polygon size filters:
min_area_m2,max_area_m2. - Any other OSM key still filters through
tagsaskey,key=value, or a numeric compare such asele>500.
Indexes
Plan queries so they can use these families. Always include a spatial anchor: bbox, location plus radius, within, or osm_ids. Tag-only scans are rejected.
| Index | On | What it speeds up |
|---|---|---|
GiST on geom | all three | Bounding box and around envelope (geom && an envelope). Radius queries then refine with distance. |
GIN on tags | all three | Arbitrary OSM keys that are not promoted to a typed column. |
btree on (osm_type, osm_id) and osm_id | all three | osm_ids lookup, keyset pagination, and within container load. |
| btree on name | all three | Name filters. |
btree on length_m / area_m2 | line / polygon | Size filters. |
| Partial btree on typed tag columns | per table | Hot keys such as amenity, highway, building, shop, natural, landuse. Prefer those tags when they match the ask. |
- Places search uses the point-plus-polygon union (POIs that are nodes or building polygons).
- Routing reads highway-tagged rows from
osm.osm_line. - Stats histograms use the same tables and filters as GeoJSON, with larger spatial caps.
How to plan a query
- Bound the search: a viewport
bbox,locationplusradius,withinan OSM polygon, orosm_ids. Geocode named places first. - Set
typeandway_shapewhen the geometry class is known (buildings: polygon; roads: line; benches: node). - Filter with native OSM tags. There is no proprietary category tree.
- Keep a spatial bound. Country-wide tag scans are not a supported query shape.
- Count with
/v2/osm_features/stats, not by paging GeoJSON.