Skip to content
GuidesBlogPlaygroundDashboard

Get feature by type and ID

GeoJsonFeature Elements.Retrieve(ElementRetrieveParamsparameters, CancellationTokencancellationToken = default)
GET/api/v1/features/{type}/{id}

Get feature by type and ID

ParametersExpand Collapse
ElementRetrieveParams parameters
required string type

Element type (node, way, relation)

required Long id

OSM ID

ReturnsExpand Collapse
class GeoJsonFeature:

GeoJSON Feature representing an OSM element. Tags from the original OSM element are flattened directly into properties (not nested under a tags key). Metadata fields @type and @id identify the OSM element type and ID within properties.

required GeoJsonGeometry Geometry

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

required Coordinates Coordinates

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

One of the following:
IReadOnlyList<Double>
IReadOnlyList<IReadOnlyList<Double>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>>
required Type Type

Geometry type

One of the following:
"Point"Point
"LineString"LineString
"Polygon"Polygon
"MultiPoint"MultiPoint
"MultiLineString"MultiLineString
"MultiPolygon"MultiPolygon
required IReadOnlyDictionary<string, JsonElement> Properties

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.

required Type Type

Always Feature

string ID

Compound identifier in type/osm_id format

Get feature by type and ID

ElementRetrieveParams parameters = new()
{
    Type = "type",
    ID = 0,
};

var geoJsonFeature = await client.Elements.Retrieve(parameters);

Console.WriteLine(geoJsonFeature);
{
  "geometry": {
    "coordinates": [
      2.3522,
      48.8566
    ],
    "type": "Point"
  },
  "properties": {
    "@id": "bar",
    "@type": "bar",
    "amenity": "bar",
    "cuisine": "bar",
    "name": "bar"
  },
  "type": "Feature",
  "id": "node/21154906"
}
Returns Examples
{
  "geometry": {
    "coordinates": [
      2.3522,
      48.8566
    ],
    "type": "Point"
  },
  "properties": {
    "@id": "bar",
    "@type": "bar",
    "amenity": "bar",
    "cuisine": "bar",
    "name": "bar"
  },
  "type": "Feature",
  "id": "node/21154906"
}