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.

TableWhat it holdsTypical query
osm.osm_pointTagged 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.

  1. Nodes (POIs, peaks, benches): type=node.
  2. Roads, paths, rivers: type=way or type=relation, and way_shape=line.
  3. Buildings, parks, landuse: way_shape=polygon.
  4. POIs that may be a node or a building polygon: type=node,way&way_shape=polygon.
  5. Unknown mix: omit both. The API unions all three tables.

Reference mapping:

ParamsReads
type=nodeosm.osm_point
type=way&way_shape=line or type=relation&way_shape=lineosm.osm_line
type=way&way_shape=polygonosm.osm_polygon
type=node,way&way_shape=polygonpoints plus polygons
omit bothpoints, 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.

TableExtra columnsTyped tag columns (common filters)
osm_pointplace, natural, aeroway, amenity, shop, tourism, public_transport, opening_hours
osm_linelength_mhighway, railway, waterway, aerialway, boundary, admin_level, tunnel, bridge, oneway, layer, ref
osm_polygonarea_m2building, 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 tags as key, key=value, or a numeric compare such as ele>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.

IndexOnWhat it speeds up
GiST on geomall three Bounding box and around envelope (geom && an envelope). Radius queries then refine with distance.
GIN on tagsall threeArbitrary OSM keys that are not promoted to a typed column.
btree on (osm_type, osm_id) and osm_idall threeosm_ids lookup, keyset pagination, and within container load.
btree on nameall threeName filters.
btree on length_m / area_m2line / polygonSize filters.
Partial btree on typed tag columnsper 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

  1. Bound the search: a viewport bbox, location plus radius, within an OSM polygon, or osm_ids. Geocode named places first.
  2. Set type and way_shape when the geometry class is known (buildings: polygon; roads: line; benches: node).
  3. Filter with native OSM tags. There is no proprietary category tree.
  4. Keep a spatial bound. Country-wide tag scans are not a supported query shape.
  5. Count with /v2/osm_features/stats, not by paging GeoJSON.

See also