### Install overture-schema-common Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-common/README.md Install the library using pip. ```bash pip install overture-schema-common ``` -------------------------------- ### Install Workspace Dependencies with uv Source: https://github.com/overturemaps/schema/blob/main/README.pydantic.md Use this command to install all necessary dependencies for the entire project workspace. Ensure uv is installed and configured. ```bash uv sync --all-packages ``` -------------------------------- ### Install overture-schema-cli Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-cli/README.md Install the overture-schema-cli package using pip. ```bash pip install overture-schema-cli ``` -------------------------------- ### Install Overture Schema System Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-system/README.md Install the overture-schema-system package using pip. ```bash pip install overture-schema-system ``` -------------------------------- ### Infrastructure Example Data Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/infrastructure.mdx Provides an example of infrastructure data in JSON format, illustrating the structure defined by the schema. This example can be used for testing or demonstration purposes. ```json { "type": "infrastructure", "aeroway": "airport" } ``` -------------------------------- ### Connector Example YAML Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/transportation/connector.mdx Provides an example of a connector in YAML format. This illustrates how to structure connector data for the transportation network. ```yaml type: connector geometry: type: Point coordinates: [-73.985664, 40.7484405] id: "a1b2c3d4-e5f6-7890-1234-567890abcdef" version: 1 ``` -------------------------------- ### Place Example JSON Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/places/place.mdx A standard example of a Place object in JSON format. Use this to see a typical data structure. ```json { "geometry": { "type": "Point", "coordinates": [ -122.4194, 37.7749 ] }, "properties": { "name": "Example Place", "categories": [ "restaurant", "cafe" ], "tags": [ "food", "drinks" ], "address": { "street": "123 Main St", "city": "Anytown", "state": "CA", "postcode": "90210", "country": "USA" } } } ``` -------------------------------- ### Install overture-schema Package Source: https://github.com/overturemaps/schema/blob/main/README.pydantic.md Install the main overture-schema package using pip. This is the primary way to access the aggregated types for convenient usage. ```shell pip install overture-schema ``` -------------------------------- ### Simple Road Segment Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/transportation/segment.mdx A basic example of a road segment. ```json { "type": "segment", "subtype": "road", "geometry": { "type": "LineString", "coordinates": [ [ -74.0060, 40.7128 ], [ -74.0050, 40.7138 ] ] }, "properties": { "road": { "surface": "asphalt", "width": 10.5 } } } ``` -------------------------------- ### Building Part Example JSON Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/buildings/building_part.mdx Provides a basic example of a building part in JSON format. This illustrates how to structure data for a building part, including its geometry and properties. ```json { "type": "building_part", "geometry": { "type": "Polygon", "coordinates": [ [ [ 13.40495, 52.52001 ], [ 13.40505, 52.52001 ], [ 13.40505, 52.52011 ], [ 13.40495, 52.52011 ], [ 13.40495, 52.52001 ] ] ] }, "properties": { "building_part_type": "wall", "levels": { "min": 0, "max": 1 }, "height": { "min": 0, "max": 3.5 } } } ``` -------------------------------- ### Building with Multiple Names Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/buildings/building.mdx An example demonstrating how to include multiple language variations for a building's name. This ensures the building can be identified across different linguistic contexts. ```json { "type": "building", "geometry": { "type": "Polygon", "coordinates": [ [ [ 13.40495, 52.52001 ], [ 13.40505, 52.52001 ], [ 13.40505, 52.52011 ], [ 13.40495, 52.52011 ], [ 13.40495, 52.52001 ] ] ] }, "properties": { "name": "Example Building", "name_en": "Example Building", "name_de": "Beispielgebäude", "name_es": "Edificio de Ejemplo", "name_fr": "Bâtiment Exemple", "name_zh": "示例建筑" } } ``` -------------------------------- ### Polygon Building Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/buildings/building.mdx An example of a building represented by a single Polygon geometry. This is the most basic form of a building feature. ```json { "type": "building", "geometry": { "type": "Polygon", "coordinates": [ [ [ 13.40495, 52.52001 ], [ 13.40505, 52.52001 ], [ 13.40505, 52.52011 ], [ 13.40495, 52.52011 ], [ 13.40495, 52.52001 ] ] ] }, "properties": { "name": "Example Building" } } ``` -------------------------------- ### Sand Dune Example (Polygon) Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/land.mdx Provides a JSON example of a sand dune feature, demonstrating the expected structure for a Polygon geometry and its properties. ```json { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ 10.0, 10.0 ], [ 10.0, 20.0 ], [ 20.0, 20.0 ], [ 20.0, 10.0 ], [ 10.0, 10.0 ] ] ] }, "properties": { "natural": "sand" } } ``` -------------------------------- ### Perspectives Division Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division.mdx An example of a division that might include perspective-specific data. This demonstrates extensibility. ```json { "id": "USA-CA-SF-BAY", "name": "San Francisco Bay Area", "country_code": "US", "country_name": "United States", "type": "metropolitan_area", "parent_id": "USA-CA", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.520722, 37.812178 ], [ -122.520722, 37.100000 ], [ -121.300000, 37.100000 ], [ -121.300000, 37.812178 ], [ -122.520722, 37.812178 ] ] ] }, "perspectives": { "tourism": { "attractions": [ "Golden Gate Bridge", "Alcatraz Island" ] } }, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ``` -------------------------------- ### Forest Land Cover Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/land_cover.mdx An example of a forest land cover feature. This demonstrates the expected structure and properties for forest data. ```json { "type": "Feature", "version": "1.0.0", "id": "land_cover-forest-123", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.4194, 37.7749 ], [ -122.4194, 37.7759 ], [ -122.4184, 37.7759 ], [ -122.4184, 37.7749 ], [ -122.4194, 37.7749 ] ] ] }, "properties": { "land_cover": { "class": "forest", "confidence": 0.95, "source": "overture", "source_id": "forest-feature-abc", "timestamp": "2023-01-01T10:00:00Z", "version": "1.0", "area": 10000, "area_units": "m2", "attributes": { "tree_density": "high" } } } } ``` -------------------------------- ### River Example YAML Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/water.mdx Provides an example of a river feature using the water schema. This snippet shows a basic river definition. ```json { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [ 13.404955, 52.520008 ], [ 13.4050, 52.5201 ] ] }, "properties": { "type": "water", "water": { "type": "river" } } } ``` -------------------------------- ### Land Use Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/land_use.mdx Provides an example of the Land Use data structure in JSON format. This helps in visualizing how land use features are represented. ```json import CodeBlock from '@theme/CodeBlock'; import JSONSchemaViewer from "@theme/JSONSchemaViewer"; import generateResolverOptions from "@site/src/components/shared-libs/generateResolverOptions" import yamlLoad from "@site/src/components/yamlLoad" import LandUseSchema from "!!raw-loader!@site/docs/_schema/base/land_use.yaml"; import LandUseExample from "!!raw-loader!@site/docs/_examples/base/land-use-example.yaml"; import LandUseExample2 from "!!raw-loader!@site/docs/_examples/base/land-use-example.yaml"; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; { JSON.stringify(yamlLoad(LandUseExample), null, 2) } ``` -------------------------------- ### Overture Names Property Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/concepts/names.mdx An example of the 'names' property structure in the Overture schema, demonstrating primary, common, and rules for different name variants and languages. ```json { "primary": "New York", "common": { "br": "Evrog Nevez", "el": "Νέα Υόρκη", "es": "Nueva York", "be-Latn-tarask": "Нью-Ёрк" }, "rules": [ { "value": "City of New York", "variant": "official", "language": null }, { "value": "Nueva Ámsterdam", "variant": "alternate", "language": "es" }, { "value": "Big Apple", "variant": "alternate", "language": null }, { "value": "La Gran Manzana", "variant": "alternate", "language": "es" } ] } ``` -------------------------------- ### Bathymetry Example Data Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/bathymetry.mdx Provides an example of bathymetry data in JSON format, illustrating how to structure depth information with geometric data. ```json { "geometry": { "type": "Polygon", "coordinates": [ [ [ 13.40495, 52.520008 ], [ 13.40495, 52.520008 ], [ 13.40495, 52.520008 ], [ 13.40495, 52.520008 ] ] ] }, "properties": { "type": "bathymetry", "level": 1, "depth": -10, "source": "example_source", "source_id": "ex123", "timestamp": "2023-01-01T10:00:00Z", "metadata": { "accuracy": "high" } } } ``` -------------------------------- ### Access Restriction Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/transportation/segment.mdx This example shows how to define access restrictions for a road segment. It specifies conditions under which vehicles are not allowed to pass. ```yaml type: "Feature" geometry: { "type": "LineString", "coordinates": [ [-73.99003, 40.73317], [-73.98991, 40.73328] ] } properties: { "@id": "seg-2", "type": "road", "access_restriction": { "type": "no_vehicles", "description": "Private road, only for residents" } } ``` -------------------------------- ### Place Example with Alternate Categories JSON Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/places/place.mdx An example of a Place object demonstrating the use of alternate category identifiers. This shows flexibility in categorization. ```json { "geometry": { "type": "Point", "coordinates": [ -73.9857, 40.7484 ] }, "properties": { "name": "Another Example Place", "categories": [ "tourist_attraction", "landmark" ], "tags": [ "sightseeing", "history" ], "address": { "street": "456 Oak Ave", "city": "Metropolis", "state": "NY", "postcode": "10001", "country": "USA" } } } ``` -------------------------------- ### Prominent River Example with Wikidata YAML Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/base/water.mdx Demonstrates a prominent river feature, including Wikidata information. This example showcases how to enrich water features with external data. ```json { "type": "Feature", "geometry": { "type": "LineString", "coordinates": [ [ -0.1278, 51.5078 ], [ -0.1279, 51.5079 ] ] }, "properties": { "type": "water", "water": { "type": "river", "wikidata": "Q183" } } } ``` -------------------------------- ### Simple Road Segment Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/transportation/segment.mdx This example demonstrates a basic road segment definition using YAML. It includes essential properties like geometry and type. ```yaml type: "Feature" geometry: { "type": "LineString", "coordinates": [ [-73.99003, 40.73317], [-73.98991, 40.73328] ] } properties: { "@id": "seg-1", "type": "road", "road_type": "secondary", "lanes": { "forward": 1, "backward": 1 }, "speed_limit": { "value": 30, "unit": "km/h" } } ``` -------------------------------- ### Heading Scoping Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/concepts/scoping-rules.mdx Limits access rules to specific travel directions. This example restricts segment access based on whether travel is forward or backward. ```yaml access: - "all" when: heading: forward --- access: - "bus" when: heading: backward ``` -------------------------------- ### Purpose of Use Scoping Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/concepts/scoping-rules.mdx Restricts access based on the traveler's purpose. This example limits access to a hotel driveway, allowing only customers or those using it as a destination. ```yaml access: - "hotel" when: using: - "customer" - "destination" --- access: - "none" when: using: - "through_traffic" ``` -------------------------------- ### Temporal Scoping Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/concepts/scoping-rules.mdx This example illustrates a road segment with a temporally-scoped access restriction. The 'when' property, using the 'during' sub-property, limits the rule's applicability to specific recurring time ranges defined by the OpenStreetMap opening hours specification. ```yaml access: # ... rules: - rule: # ... access: - "no_access: all" # Scopes the rule to weekdays between 3PM and 6PM when: during: "Mon-Fri 15:00-18:00" ``` -------------------------------- ### Generate Documentation for a Single Theme (CLI) Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-codegen/README.md Generate documentation for a specific theme by providing a tag and output directory. ```bash overture-codegen generate --format markdown --tag overture:theme=buildings --output-dir out/ ``` -------------------------------- ### Country Division Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division.mdx An example of a division representing a country. This includes basic information and geometry. ```json { "id": "USA", "name": "United States", "country_code": "US", "country_name": "United States", "type": "country", "parent_id": null, "geometry": { "type": "Polygon", "coordinates": [ [ [ -171.715556, 58.6475 ], [ -171.715556, 18.9175 ], [ -66.953125, 18.9175 ], [ -66.953125, 58.6475 ], [ -171.715556, 58.6475 ] ] ] }, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ``` -------------------------------- ### Address Example JSON Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/addresses/address.mdx Provides a sample address in JSON format, demonstrating the structure defined by the schema. ```json { "id": "abc-123", "building": "Overture Maps Foundation", "houseNumber": "1", "street": "Main Street", "unit": "Suite 100", "level": "1", "city": "San Francisco", "state": "CA", "postcode": "94107", "country": "USA", "countryCode": "US", "countryName": "United States", "region": "Bay Area", "coordinates": { "latitude": 37.7749, "longitude": -122.4194 }, "geometry": { "type": "Point", "coordinates": [ -122.4194, 37.7749 ] } } ``` -------------------------------- ### Region Division Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division.mdx An example of a division representing a region within a country. It includes a parent_id linking it to its country. ```json { "id": "USA-CA", "name": "California", "country_code": "US", "country_name": "United States", "type": "state", "parent_id": "USA", "geometry": { "type": "Polygon", "coordinates": [ [ [ -124.245776, 42.009515 ], [ -124.245776, 32.534156 ], [ -114.131331, 32.534156 ], [ -114.131331, 42.009515 ], [ -124.245776, 42.009515 ] ] ] }, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ``` -------------------------------- ### Pydantic Custom Constraint Example Source: https://github.com/overturemaps/schema/blob/main/PYDANTIC_GUIDE.md Example of using a custom constraint for Pydantic field validation, such as language tag validation. ```python LanguageTagConstraint() ``` -------------------------------- ### Generate Markdown Documentation (CLI) Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-codegen/README.md Use this command to generate markdown documentation for all themes. Specify the output directory. ```bash overture-codegen generate --format markdown --output-dir docs/schema/reference ``` -------------------------------- ### Fetch Sample Data using DuckDB Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-codegen/README.md Fetch a fresh sample of Overture data using DuckDB. This command loads the spatial extension, attaches the latest Overture database, and selects sample data, converting geometry to text. The output is piped to `jq` for JSON processing. ```bash duckdb -json \ -c "load spatial" \ -c "attach 'http://labs.overturemaps.org/data/latest.ddb' as overture" \ -c "select to_json(columns(*)) from ( select * REPLACE ST_AsText(geometry) as geometry from overture.place USING SAMPLE 1 )" \ | jq . ``` -------------------------------- ### Population Division Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division.mdx An example of a division that might include population data. Note that population is not a standard field in the base schema. ```json { "id": "USA-CA-SF", "name": "San Francisco", "country_code": "US", "country_name": "United States", "type": "county", "parent_id": "USA-CA", "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.520722, 37.812178 ], [ -122.520722, 37.691711 ], [ -122.358431, 37.691711 ], [ -122.358431, 37.812178 ], [ -122.520722, 37.812178 ] ] ] }, "population": 873965, "created_at": "2023-01-01T00:00:00Z", "updated_at": "2023-01-01T00:00:00Z" } ``` -------------------------------- ### Run All Project Checks Source: https://github.com/overturemaps/schema/blob/main/README.pydantic.md Execute this command to run all tests and code quality checks defined in the project's Makefile. This ensures the project adheres to quality standards. ```bash make check ``` -------------------------------- ### MultiPolygon Building Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/buildings/building.mdx An example of a building represented by a MultiPolygon geometry, which can include multiple disjoint polygons. This is useful for complex building shapes. ```json { "type": "building", "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 13.40495, 52.52001 ], [ 13.40505, 52.52001 ], [ 13.40505, 52.52011 ], [ 13.40495, 52.52011 ], [ 13.40495, 52.52001 ] ] ], [ [ [ 13.41495, 52.53001 ], [ 13.41505, 52.53001 ], [ 13.41505, 52.53011 ], [ 13.41495, 52.53011 ], [ 13.41495, 52.53001 ] ] ] ] }, "properties": { "name": "Example MultiPolygon Building" } } ``` -------------------------------- ### Register Tag Provider via Entry Point Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-system/README.md Register a custom tag provider using the project's entry points configuration. This makes the provider discoverable by the system. ```toml [project.entry-points."overture.tag_providers"] feature = "overture.schema.system.discovery.tag_providers:feature_provider" ``` -------------------------------- ### Run Tests for a Specific Package Source: https://github.com/overturemaps/schema/blob/main/README.pydantic.md Use this command to run tests for a particular package within the project. Replace 'packages/overture-schema-buildings-theme/' with the target package path. ```bash uv run pytest packages/overture-schema-buildings-theme/ ``` -------------------------------- ### Example: Country, Maritime Class Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division_area.mdx Example of a division area representing a country with the 'maritime' class. This is used for defining national maritime boundaries. ```json { "type": "country", "id": "USA", "name": "United States", "country_code": "US", "tags": [ "federal republic" ], "boundary": { "type": "polygon", "coordinates": [ [ [ -71.0589, 42.3601 ], [ -71.0589, 42.3601 ], [ -71.0589, 42.3601 ] ] ] }, "class": "maritime", "wikidata_id": "Q30" } ``` -------------------------------- ### Land Region Division Boundary Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division_boundary.mdx An example of a land region division boundary. This showcases the typical structure for a country or regional border. ```json { "type": "division_boundary", "subtype": "region", "geometry": { "type": "LineString", "coordinates": [ [ -103.0, 49.0 ], [ -102.0, 49.0 ] ] }, "properties": { "name": "US-Canada border", "names": { "common": "US-Canada border", "official": "US-Canada border" }, "country_code": "CA", "tags": [ "border" ] } } ``` -------------------------------- ### Model Discovery Configuration Source: https://github.com/overturemaps/schema/blob/main/packages/overture-schema-system/README.md Configure model discovery using TOML in `pyproject.toml` under `[project.entry-points."overture.models"]`. This maps a model name to its Python import path, allowing tools to discover and load models. ```toml [project.entry-points."overture.models"] building = "overture.schema.buildings:Building" building_part = "overture.schema.buildings:BuildingPart" ``` -------------------------------- ### Example: Country, Land Class Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division_area.mdx Example of a division area representing a country with the 'land' class. This structure is useful for defining national land boundaries. ```json { "type": "country", "id": "USA", "name": "United States", "country_code": "US", "tags": [ "federal republic" ], "boundary": { "type": "polygon", "coordinates": [ [ [ -171.707155, 19.421341 ], [ -171.707155, 19.421341 ], [ -171.707155, 19.421341 ] ] ] }, "class": "land", "wikidata_id": "Q30" } ``` -------------------------------- ### Disputed Boundary Example Source: https://github.com/overturemaps/schema/blob/main/docs/schema/reference/divisions/division_boundary.mdx An example of a disputed boundary. This type of boundary may not align with official division borders and represents a treaty or contested line. ```json { "type": "division_boundary", "subtype": "country", "geometry": { "type": "LineString", "coordinates": [ [ 34.0, 31.0 ], [ 34.5, 31.5 ] ] }, "properties": { "name": "Israel-Palestine border", "names": { "common": "Israel-Palestine border", "official": "Israel-Palestine border" }, "country_code": "IL", "tags": [ "disputed", "border" ] } } ```