Skip to content
GuidesBlogPlaygroundDashboard

Query features by spatial predicate, bounding box, or H3 cell

client.Elements.Query(ctx, query) (*FeatureCollection, error)
GET/api/v1/features

Query features by spatial predicate, bounding box, or H3 cell

ParametersExpand Collapse
query ElementQueryParams
Bbox param.Field[string]optional

Legacy shorthand. Bounding box: south,west,north,east. Use spatial predicates (near, within, intersects) instead.

Contains param.Field[string]optional

Geometry that features must contain

Crosses param.Field[string]optional

Geometry that features must cross

Cursor param.Field[string]optional

Cursor for pagination

Format param.Field[string]optional

Response format. json (default) returns paginated GeoJSON. geojson/csv/ndjson stream via chunked transfer encoding.

H3 param.Field[string]optional

Legacy shorthand. H3 cell index. Use spatial predicates instead.

Intersects param.Field[string]optional

Geometry that features must intersect

Limit param.Field[int64]optional

Maximum results (default 100, max 10000)

Near param.Field[string]optional

Point geometry for proximity search (lat,lng). Requires radius.

OutputBuffer param.Field[float64]optional

Buffer geometry by meters

OutputCentroid param.Field[bool]optional

Replace geometry with centroid

OutputFields param.Field[string]optional

Comma-separated property fields to include

OutputGeometry param.Field[bool]optional

Include geometry (default true)

OutputInclude param.Field[string]optional

Extra computed fields: bbox, distance, center

OutputPrecision param.Field[int64]optional

Coordinate decimal precision (1-15, default 7)

OutputSimplify param.Field[float64]optional

Simplify geometry tolerance in meters

OutputSort param.Field[string]optional

Sort by: distance, name, osm_id

Radius param.Field[float64]optional

Search radius in meters (for near) or buffer distance (for other predicates)

Touches param.Field[string]optional

Geometry that features must touch

Type param.Field[string]optional

Element types (comma-separated: node,way,relation)

Within param.Field[string]optional

Geometry that features must be within

ReturnsExpand Collapse
type FeatureCollection struct{…}

GeoJSON FeatureCollection (RFC 7946). For paginated endpoints, metadata is returned in HTTP response headers rather than the body:

Header Description
X-Limit Requested result limit
X-Has-More true if more results exist
X-Next-Cursor Opaque cursor for next page (cursor pagination)
X-Next-Offset Numeric offset for next page (offset pagination)
Link RFC 8288 rel="next" link to the next page

Content-Type is application/geo+json.

Features []GeoJsonFeature

Array of GeoJSON Feature objects

GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints.

Coordinates GeoJsonGeometryCoordinatesUnion

Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc.

One of the following:
type GeoJsonGeometryCoordinatesPoint []float64

[longitude, latitude] or [longitude, latitude, elevation]

type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64

Array of [lng, lat] positions

type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64

Array of linear rings / line strings

type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64

Array of polygons

Type GeoJsonGeometryType

Geometry type

One of the following:
const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"
const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"
const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"
const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"
const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"
const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"
Properties map[string, unknown]

OSM tags flattened as key-value pairs, plus @type (node/way/relation) and @id (OSM ID) metadata fields. May include distance_m for proximity queries.

Type GeoJsonFeatureType

Always Feature

ID stringoptional

Compound identifier in type/osm_id format

Type FeatureCollectionType

Always FeatureCollection

Query features by spatial predicate, bounding box, or H3 cell

package main

import (
  "context"
  "fmt"

  "github.com/plazafyi/plaza-go"
  "github.com/plazafyi/plaza-go/option"
)

func main() {
  client := githubcomplazafyiplazago.NewClient(
    option.WithAPIKey("My API Key"),
  )
  featureCollection, err := client.Elements.Query(context.TODO(), githubcomplazafyiplazago.ElementQueryParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", featureCollection.Features)
}
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "@id": "bar",
        "@type": "bar",
        "amenity": "bar",
        "cuisine": "bar",
        "name": "bar"
      },
      "type": "Feature",
      "id": "node/21154906"
    }
  ],
  "type": "FeatureCollection"
}
Returns Examples
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "@id": "bar",
        "@type": "bar",
        "amenity": "bar",
        "cuisine": "bar",
        "name": "bar"
      },
      "type": "Feature",
      "id": "node/21154906"
    }
  ],
  "type": "FeatureCollection"
}