Skip to content

Commit

Permalink
Add linking between datasets
Browse files Browse the repository at this point in the history
Hazard ID and Exposure ID fields should render as links
to respective pages. Requires changing id to dataset_id
to not conflict with page ids.
  • Loading branch information
lydiascarf committed Jun 12, 2024
1 parent 2e874a3 commit 9f04aca
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 10 deletions.
7 changes: 5 additions & 2 deletions _data/schemas/rdl-02.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# RDS-attributes: common fields
# Contribution (dataset)
dataset_fields:
- field_name: id
- field_name: dataset_id
label: ID of dataset
required: true
- field_name: title
Expand Down Expand Up @@ -378,7 +378,10 @@ loss:
- probabilistic
- field_name: hazard_id
label: Hazard ID
display_template: display/dataset_link.html
- field_name: exposure_id
label: Exposure ID
display_template: display/dataset_link.html
- field_name: vulnerability_id
label: Vulnerability ID
label: Vulnerability ID
display_template: display/dataset_link.html
2 changes: 1 addition & 1 deletion _datasets/afghanistan-drought-risk.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contact_point:
creator:
name: GFDRR
url: https://www.gfdrr.org
dataset_id: AFG_lss-drought
description: Annual average losses in agricultural production (USD) and affected population,
both for the baseline reference and future projections (2050)
details: "To better understand natural hazard and disaster risk, the World Bank and\
Expand All @@ -15,7 +16,6 @@ details: "To better understand natural hazard and disaster risk, the World Bank
\ This publication describes the applied methods and main results of the project."
exposure: null
hazard: null
id: AFG_lss-drought
license: CC-BY-4.0
loss:
approach: analytical
Expand Down
2 changes: 1 addition & 1 deletion _datasets/afghanistan-flood-risk.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contact_point:
creator:
name: GFDRR
url: https://www.gfdrr.org
dataset_id: AFG_lss-flood
description: Average Annual Losses (AAL) for current population (AALpop), current
asset (AALnowUSD), population SSP scenarios at 2050 (AALpopSP1-5), asset SSP scenarios
at 2050 (AAL_usd_SP1-5).
Expand All @@ -16,7 +17,6 @@ details: "To better understand natural hazard and disaster risk, the World Bank
\ This publication describes the applied methods and main results of the project."
exposure: null
hazard: null
id: AFG_lss-flood
license: CC-BY-4.0
loss:
approach: analytical
Expand Down
2 changes: 1 addition & 1 deletion _datasets/global-flood-depth-damage-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ contact_point:
name: Mattia Amadio
creator:
name: Huizinga, J.
dataset_id: https://publications.jrc.ec.europa.eu/repository/handle/JRC105688
description: This dataset contains damage curves depicting fractional damage function
of water depth as well as maximum damage values for a variety of assets and land
use classes.
Expand All @@ -21,7 +22,6 @@ details: Based on an extensive literature survey concave damage curves have been
assessment in countries where no damage model is currently available.
exposure: null
hazard: null
id: https://publications.jrc.ec.europa.eu/repository/handle/JRC105688
license: CC-BY-4.0
loss: null
project: null
Expand Down
2 changes: 1 addition & 1 deletion _datasets/global-flood-hazard-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ contact_point:
creator:
name: Fathom
url: https://www.fathom.global/
dataset_id: FTH_v3
description: Probabilistic modelling of fluvial and pluvial flood hazard
details: "The FATHOM flood-hazard model is a global gridded dataset of flood hazard\
\ produced at the global scale. It provides flood extent and water depth to ground\
Expand Down Expand Up @@ -33,7 +34,6 @@ hazard:
intensity: wd:cm
occurrence_range: 1/10 to 1/1000 years
processes: coastal_flood, fluvial_flood, pluvial_flood
id: FTH_v3
license: Commercial
loss: null
project: null
Expand Down
2 changes: 1 addition & 1 deletion _datasets/rooftop-classification-map-of-dominica.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ creator:
email: [email protected]
name: Isabelle Tingzon
url: https://issa-tingzon.github.io/
dataset_id: ortho_DOM
description: Building footprint polygons of Dominica with corresponding roof type
and roof material attributes predicted from RGB orthophotos taken in 2018-2019,
in the aftermath of Hurricane Maria.
Expand All @@ -26,7 +27,6 @@ exposure:
quantity_kind: area
taxonomy: Custom roof type and roof material taxonomy
hazard: null
id: ortho_DOM
license: CC-BY-4.0
loss: null
project: Digital Earth for Resilient Housing and Infrastructure in the Caribbean
Expand Down
2 changes: 1 addition & 1 deletion _datasets/rooftop-classification-map-of-saint-lucia.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ creator:
email: [email protected]
name: Isabelle Tingzon
url: https://issa-tingzon.github.io/
dataset_id: ortho_LCA
description: 'Building footprint polygons of Saint Lucia with corresponding roof type
and roof material attributes predicted from RGB orthophotos taken in 2022. '
details: 'The vector dataset depicts building footprint polygons of Saint Lucia with
Expand All @@ -24,7 +25,6 @@ exposure:
quantity_kind: area
taxonomy: Custom roof type and roof material taxonomy
hazard: null
id: ortho_LCA
license: CC-BY-4.0
loss: null
project: Digital Earth for Resilient Housing and Infrastructure in the Caribbean
Expand Down
22 changes: 22 additions & 0 deletions _includes/display/dataset_link.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<tr>
{% assign field_name = include.field.field_name %}
{% assign risk_data_type = page["risk_data_type"] | first %}
{% if field_name == "hazard_id" %}
{% assign linked_id = page[risk_data_type].hazard_id %}
{% elsif field_name == "exposure_id" %}
{% assign linked_id = page[risk_data_type].exposure_id %}
{% endif %}

{% assign linked_dataset = site.datasets | where:"dataset_id", linked_id | first %}
{% if linked_dataset %}
<th>{{ include.field.label | split:" " | first }}</th>
<td class="{{field_name}}">
<a href="{{ linked_dataset.url }}">{{ linked_dataset.title }}</a>
</td>
{% else %}
<th>{{ include.field.label }}</th>
<td class="{{field_name}}">
{{ linked_id }}
</td>
{% endif %}

4 changes: 2 additions & 2 deletions import/rdl2jkan.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def make_dataset_frontmatter(dataset):
# required; throw if missing
"contact_point": dataset["contact_point"],
"creator": dataset["creator"],
"id": dataset["id"],
"dataset_id": dataset["id"],
"license": dataset["license"],
"publisher": dataset["publisher"],
"resources": [make_resource(resource) for resource in dataset["resources"]],
Expand Down Expand Up @@ -349,7 +349,7 @@ def write_frontmatter(metadata, output_path):
dataset_frontmatter = make_dataset_frontmatter(dataset_json)
write_frontmatter(dataset_frontmatter, datasets_output_dir)
except Exception as e:
logging.error(f"While writing {dataset_json.get("title", "a dataset with a missing title")} (id: {dataset_json.get("id", "missing")})",exc_info=e)
logging.error(f"While writing {dataset_json.get("title", "a dataset with a missing title")} (dataset_id: {dataset_json.get("dataset_id", "missing")})",exc_info=e)


print("\nAll done! Please enjoy your datasets :)\n",
Expand Down

0 comments on commit 9f04aca

Please sign in to comment.