Skip to content

Commit

Permalink
add variable description to table extension
Browse files Browse the repository at this point in the history
  • Loading branch information
andresfchamorro committed Nov 13, 2024
1 parent ea5628b commit 90ecaaf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def load_existing_collection(collection_path: str) -> Collection:

# Function to create a new STAC item
def create_new_item(
sources: pd.DataFrame, column_types: dict, item_id: str
sources: pd.DataFrame, column_types: dict, item_id: str, feature_catalog: pd.DataFrame
) -> tuple[Item, str]:
# Define geometry and bounding box (you may want to customize these)
geom = {
Expand Down Expand Up @@ -132,7 +132,7 @@ def create_new_item(
TableExtension.add_to(item)
table_extension = TableExtension.ext(item, add_if_missing=True)
table_extension.columns = [
{"name": col, "type": dtype} for col, dtype in column_types.items()
{"name": col, "description": feature_catalog.loc[col, "description"],"type": dtype} for col, dtype in column_types.items()
]

# Add asset
Expand Down Expand Up @@ -194,7 +194,7 @@ def main():
collection = load_existing_collection(collection_path)

# Create a new item
new_item, item_title = create_new_item(metadata["sources"], column_types, item_id)
new_item, item_title = create_new_item(metadata["sources"], column_types, item_id, feature_catalog)

# Add the new item to the collection
collection.add_item(new_item, title=item_title)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,21 @@
"table:columns": [
{
"name": "pop",
"description": "Sum of Gridded Population, 2020",
"type": "float32"
},
{
"name": "pop_flood",
"description": "Sum of population exposed to floods greater than 15 cm, 1 in 100 return period",
"type": "float64"
},
{
"name": "pop_flood_pct",
"description": "Percent of population exposed to floods greater than 15 cm, 1 in 100 return period",
"type": "float64"
}
],
"datetime": "2024-11-12T16:00:41.760032Z"
"datetime": "2024-11-13T10:20:46.833394Z"
},
"links": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
}
},
"themes": "Demographics",
"datetime": "2024-11-12T15:57:43.803354Z"
"datetime": "2024-11-13T10:17:10.841416Z"
},
"links": [
{
Expand Down

0 comments on commit 90ecaaf

Please sign in to comment.