---
description: "Built-in and custom RDF prefixes for semantic metadata in datasets.yaml."
---

# RDF Prefixes in datasets.yaml

This guide covers how to use RDF (Resource Description Framework) prefixes in `datasets.yaml` to add semantic metadata to your datasets. For the full specification including datapackage.json output and advanced use cases, see [Data Package Metadata Extensibility](datapackage-extra-metadata.md).

## Standard Prefixes

Sunstone includes these built-in prefixes that are always available (no need to declare them):

| Prefix | Namespace | Purpose |
|--------|-----------|---------|
| `dcat:` | `http://www.w3.org/ns/dcat#` | Data Catalog Vocabulary |
| `dcat-si:` | `https://sunstone.institute/rdf/data#` | Sunstone dataset-level terms (methodology) |
| `dct:` | `http://purl.org/dc/terms/` | Dublin Core Terms |
| `dwc:` | `http://rs.tdwg.org/dwc/terms/` | Darwin Core (biodiversity) |
| `geo:` | `http://www.opengis.net/ont/geosparql#` | OGC GeoSPARQL (geometry classes and datatypes) |
| `gtio-i:` | `https://sunstone.institute/rdf/gtio/0.3/interventions#` | GTIO interventions vocabulary |
| `gtio-t:` | `https://sunstone.institute/rdf/gtio/0.3/threats#` | GTIO threats vocabulary |
| `prov:` | `http://www.w3.org/ns/prov#` | W3C Provenance Ontology |
| `qudt:` | `http://qudt.org/schema/qudt/` | Quantities, Units, Dimensions |
| `rdf:` | `http://www.w3.org/1999/02/22-rdf-syntax-ns#` | RDF syntax |
| `rdfs:` | `http://www.w3.org/2000/01/rdf-schema#` | RDF Schema |
| `schema:` | `http://schema.org/` | Schema.org vocabulary |
| `si:` | `https://sunstone.institute/rdf/vocab#` | Sunstone-specific properties |
| `si30:` | `https://sunstone.institute/rdf/threat/` | Sunstone threat references |
| `skos:` | `http://www.w3.org/2004/02/skos/core#` | Simple Knowledge Organization |
| `sosa:` | `http://www.w3.org/ns/sosa/` | Sensor, Observation, Sample, Actuator |

The full set is exported as `sunstone.STANDARD_RDF_PREFIXES` for programmatic use.

## Defining Prefixes

Prefixes can be defined at three levels, with this precedence order (highest first):

1. **Dataset-level** — on an individual input or output
2. **Top-level** — at the root of `datasets.yaml`
3. **Defaults section** — in the `defaults:` block

### Using the defaults section (recommended)

Define prefixes once and they apply to all datasets:

```yaml
min_sunstone_version: 1.20.0
defaults:
  rdfPrefixes:
    si: "https://sunstone.institute/rdf/vocab#"
    si30: "https://sunstone.institute/rdf/threat/"
    dcat: "http://www.w3.org/ns/dcat#"

outputs:
  - title: Climate Dataset
    name: climate-dataset
    path: outputs/climate.csv
    si:monitorsThreat: si30:27
    si:category: environmental
    dcat:theme: climate
    schema:
      fields:
        - name: year
          type: integer
```

### Top-level prefixes

```yaml
min_sunstone_version: 1.20.0
rdfPrefixes:
  si: "https://sunstone.institute/rdf/vocab#"
  si30: "https://sunstone.institute/rdf/threat/"

outputs:
  - title: Climate Dataset
    name: climate-dataset
    path: outputs/climate.csv
    si:monitorsThreat: si30:27
    schema:
      fields:
        - name: year
          type: integer
```

### Per-dataset override

A dataset can override inherited prefixes:

```yaml
min_sunstone_version: 1.20.0
defaults:
  rdfPrefixes:
    si: "https://sunstone.institute/rdf/vocab#"

outputs:
  - title: Special Dataset
    name: special-dataset
    path: outputs/special.csv
    rdfPrefixes:
      si: "https://other.example.com/vocab#"  # overrides default
    si:customProp: value
    schema:
      fields:
        - name: id
          type: integer
```

## Adding RDF Properties

Any key containing `:` (or starting with `http://`/`https://`) on a dataset entry is treated as a custom RDF property. Standard dataset fields (`title`, `name`, `path`, `schema`, `licenses`, `source`, `strict`, `rdfPrefixes`, `publish`) are excluded.

### Using prefixed names

```yaml
min_sunstone_version: 1.20.0
outputs:
  - title: Climate Dataset
    name: climate-dataset
    path: outputs/climate.csv
    si:monitorsThreat: si30:27      # both key and value use prefixes
    si:category: environmental       # value is a plain string
    dcat:theme: climate
    schema:
      fields:
        - name: year
          type: integer
```

### Using full URIs

You can also use full URIs directly without defining prefixes:

```yaml
min_sunstone_version: 1.20.0
outputs:
  - title: My Dataset
    name: my-dataset
    path: outputs/data.csv
    https://sunstone.institute/rdf/vocab#datasetType: observational
    schema:
      fields:
        - name: id
          type: integer
```

## Default Properties

RDF properties in the `defaults:` section are inherited by all datasets:

```yaml
min_sunstone_version: 1.20.0
defaults:
  rdfPrefixes:
    si: "https://sunstone.institute/rdf/vocab#"
  si:organization: "Sunstone Institute"
  si:license: "CC-BY-4.0"

outputs:
  - title: Dataset 1
    name: dataset-1
    path: outputs/data1.csv
    si:theme: climate
    schema:
      fields:
        - name: id
          type: integer

  - title: Dataset 2
    name: dataset-2
    path: outputs/data2.csv
    si:theme: biodiversity
    schema:
      fields:
        - name: id
          type: integer
```

Both datasets inherit `si:organization` and `si:license` from defaults. Dataset-level properties override defaults when they share the same key.

## Prefix Expansion

When building a datapackage (`sunstone package build`), prefixes in both keys and values are expanded to full URIs:

```yaml
# In datasets.yaml
si:monitorsThreat: si30:27
```

Becomes in `datapackage.json`:

```json
"https://sunstone.institute/rdf/vocab#monitorsThreat": "https://sunstone.institute/rdf/threat/27"
```

Non-string values (numbers, booleans, lists) are preserved as-is without expansion.

## Automatic Type Properties

Every generated `datapackage.json` automatically includes DCAT type annotations:

- **Package level**: `rdf:type` -> `dcat:Dataset`
- **Resource level**: `rdf:type` -> `dcat:Distribution`

No configuration needed — this makes all generated packages compatible with DCAT-based data catalogs.

## Methodology Property

The `dcat-si:methodology` property has special handling. When its value is a local file path, it is resolved as a relative URI against `publish.as` during publishing:

```yaml
publish:
  enabled: true
  to: gs://my-bucket/datasets/project/
  as: https://cdn.example.com/datasets/project/

defaults:
  rdfPrefixes:
    si: "https://sunstone.institute/rdf/vocab#"
  dcat-si:methodology: docs/default-methodology.md

outputs:
  - title: Climate Dataset
    name: climate-dataset
    path: outputs/climate.csv
    dcat-si:methodology: docs/climate-methodology.md  # per-dataset override
    schema:
      fields:
        - name: year
          type: integer
```

On publish, the value becomes `https://cdn.example.com/datasets/project/docs/climate-methodology.md` and the file is uploaded alongside the data.

`datapackage.json` carries the methodology under both `https://sunstone.institute/rdf/data#methodology` and the older `https://sunstone.institute/rdf/vocab#methodology` in 1.x; 2.0 drops the older key.

## Further Reading

- Full specification with datapackage.json examples: [Data Package Metadata Extensibility](datapackage-extra-metadata.md)
- Datapackage standard: https://datapackage.org/
- DCAT vocabulary: https://www.w3.org/TR/vocab-dcat-3/
