# Datasets ## List all datasets `datasets.list() -> DatasetList` **get** `/api/v1/datasets` List all datasets ### Returns - `class DatasetList` List of all available datasets. - `datasets: Array[Dataset]` Array of dataset metadata objects - `id: String` Dataset UUID - `inserted_at: Time` Creation timestamp (UTC) - `name: String` Human-readable dataset name - `slug: String` URL-friendly identifier - `updated_at: Time` Last update timestamp (UTC) - `attribution: String` Required attribution text - `description: String` Dataset description - `license: String` License identifier (e.g. CC-BY-4.0) - `source_url: String` URL of the original data source ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) dataset_list = plaza.datasets.list puts(dataset_list) ``` #### Response ```json { "datasets": [ { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "inserted_at": "2019-12-27T18:11:19.117Z", "name": "NYC Bike Lanes", "slug": "nyc-bike-lanes", "updated_at": "2019-12-27T18:11:19.117Z", "attribution": "attribution", "description": "description", "license": "license", "source_url": "https://example.com" } ] } ``` ## Create a new dataset (admin only) `datasets.create(**kwargs) -> Dataset` **post** `/api/v1/datasets` Create a new dataset (admin only) ### Parameters - `name: String` Human-readable dataset name - `slug: String` URL-friendly identifier (lowercase, hyphens, no spaces) - `attribution: String` Required attribution text - `description: String` Dataset description - `license: String` License identifier (e.g. CC-BY-4.0) - `source_url: String` Source data URL ### Returns - `class Dataset` Metadata for a custom dataset. Datasets contain user-uploaded geospatial features separate from the OSM data. - `id: String` Dataset UUID - `inserted_at: Time` Creation timestamp (UTC) - `name: String` Human-readable dataset name - `slug: String` URL-friendly identifier - `updated_at: Time` Last update timestamp (UTC) - `attribution: String` Required attribution text - `description: String` Dataset description - `license: String` License identifier (e.g. CC-BY-4.0) - `source_url: String` URL of the original data source ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) dataset = plaza.datasets.create(name: "NYC Bike Lanes", slug: "nyc-bike-lanes") puts(dataset) ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "inserted_at": "2019-12-27T18:11:19.117Z", "name": "NYC Bike Lanes", "slug": "nyc-bike-lanes", "updated_at": "2019-12-27T18:11:19.117Z", "attribution": "attribution", "description": "description", "license": "license", "source_url": "https://example.com" } ``` ## Get dataset by ID `datasets.retrieve(id) -> Dataset` **get** `/api/v1/datasets/{id}` Get dataset by ID ### Parameters - `id: String` ### Returns - `class Dataset` Metadata for a custom dataset. Datasets contain user-uploaded geospatial features separate from the OSM data. - `id: String` Dataset UUID - `inserted_at: Time` Creation timestamp (UTC) - `name: String` Human-readable dataset name - `slug: String` URL-friendly identifier - `updated_at: Time` Last update timestamp (UTC) - `attribution: String` Required attribution text - `description: String` Dataset description - `license: String` License identifier (e.g. CC-BY-4.0) - `source_url: String` URL of the original data source ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) dataset = plaza.datasets.retrieve("id") puts(dataset) ``` #### Response ```json { "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", "inserted_at": "2019-12-27T18:11:19.117Z", "name": "NYC Bike Lanes", "slug": "nyc-bike-lanes", "updated_at": "2019-12-27T18:11:19.117Z", "attribution": "attribution", "description": "description", "license": "license", "source_url": "https://example.com" } ``` ## Delete a dataset `datasets.delete(id) -> void` **delete** `/api/v1/datasets/{id}` Delete a dataset ### Parameters - `id: String` ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) result = plaza.datasets.delete("id") puts(result) ``` ## Query features in a dataset `datasets.features(id, **kwargs) -> FeatureCollection` **get** `/api/v1/datasets/{id}/features` Query features in a dataset ### Parameters - `id: String` - `cursor: String` Cursor for pagination - `limit: Integer` Maximum results - `output_buffer: Float` Buffer geometry by meters - `output_centroid: bool` Replace geometry with centroid - `output_fields: String` Comma-separated property fields to include - `output_geometry: bool` Include geometry (default true) - `output_include: String` Extra computed fields: bbox, distance, center - `output_precision: Integer` Coordinate decimal precision (1-15, default 7) - `output_simplify: Float` Simplify geometry tolerance in meters - `output_sort: String` Sort by: distance, name, osm_id ### Returns - `class FeatureCollection` 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: Array[GeoJsonFeature]` Array of GeoJSON Feature objects - `geometry: GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `coordinates: Array[Float] | Array[Array[Float]] | Array[Array[Array[Float]]] | Array[Array[Array[Array[Float]]]]` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `Array[Float]` [longitude, latitude] or [longitude, latitude, elevation] - `Array[Array[Float]]` Array of [lng, lat] positions - `Array[Array[Array[Float]]]` Array of linear rings / line strings - `Array[Array[Array[Array[Float]]]]` Array of polygons - `type: :Point | :LineString | :Polygon | 3 more` Geometry type - `:Point` - `:LineString` - `:Polygon` - `:MultiPoint` - `:MultiLineString` - `:MultiPolygon` - `properties: Hash[Symbol, untyped]` 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: :Feature` Always `Feature` - `:Feature` - `id: String` Compound identifier in `type/osm_id` format - `type: :FeatureCollection` Always `FeatureCollection` - `:FeatureCollection` ### Example ```ruby require "plaza" plaza = Plaza::Client.new( api_key: "My API Key", environment: "local" # defaults to "production" ) feature_collection = plaza.datasets.features("id") puts(feature_collection) ``` #### Response ```json { "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" } ``` ## Domain Types ### Dataset - `class Dataset` Metadata for a custom dataset. Datasets contain user-uploaded geospatial features separate from the OSM data. - `id: String` Dataset UUID - `inserted_at: Time` Creation timestamp (UTC) - `name: String` Human-readable dataset name - `slug: String` URL-friendly identifier - `updated_at: Time` Last update timestamp (UTC) - `attribution: String` Required attribution text - `description: String` Dataset description - `license: String` License identifier (e.g. CC-BY-4.0) - `source_url: String` URL of the original data source ### Dataset List - `class DatasetList` List of all available datasets. - `datasets: Array[Dataset]` Array of dataset metadata objects - `id: String` Dataset UUID - `inserted_at: Time` Creation timestamp (UTC) - `name: String` Human-readable dataset name - `slug: String` URL-friendly identifier - `updated_at: Time` Last update timestamp (UTC) - `attribution: String` Required attribution text - `description: String` Dataset description - `license: String` License identifier (e.g. CC-BY-4.0) - `source_url: String` URL of the original data source