Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency #45

Merged
merged 2 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ Requires [Git] and [Miniconda] (or Anaconda) with Python 3.6 or newer.
1. Clone the repository and `cd` into it:

```sh
git clone https://github.com/moja-global/GCBM.Visualisation_Tool
cd GCBM.Visualisation_Tool
git clone https://github.com/moja-global/taswira
cd taswira
```

2. Create a conda environment and activate it:
Expand Down
3 changes: 2 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- nodefaults
dependencies:
- python>=3.6
- numpy
- numpy=1.19.5
- rasterio>=1.0
- shapely
- crick
Expand All @@ -15,3 +15,4 @@ dependencies:
- pylint>=2.5.2
- dash==1.13.3
- dash-leaflet==0.0.19
- MarkupSafe==2.0.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _get_version(rel_path):
description="An interactive visualization tool for GCBM",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/moja-global/GCBM.Visualisation_Tool",
url="https://github.com/moja-global/taswira",
author="moja global",
classifiers=[
'Development Status :: 3 - Alpha',
Expand Down
2 changes: 1 addition & 1 deletion src/taswira/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""A command-line tool for visualizing GCBM output."""
from .scripts.console import console

__version__ = "0.1.0"
__version__ = "0.1.1"


def main():
Expand Down
11 changes: 9 additions & 2 deletions src/taswira/scripts/ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
import os
import re
import logging

import tqdm
from terracotta import get_driver
Expand All @@ -12,7 +13,7 @@
from .metadata import get_metadata

DB_NAME = 'terracotta.sqlite'
GCBM_RASTER_NAME_PATTERN = r'.*_(?P<year>\d{4}).tiff'
GCBM_RASTER_NAME_PATTERN = r'.*_(?P<year>\d{4}).tif{1,2}'
GCBM_RASTER_KEYS = ('title', 'year')
GCBM_RASTER_KEYS_DESCRIPTION = {
'title': 'Name of indicator',
Expand Down Expand Up @@ -64,10 +65,16 @@ def ingest(rasterdir, db_results, outputdir, allow_unoptimized=False):
title = raster.get('title', raster['database_indicator'])
year = _find_raster_year(raster['path'])
unit = find_units(raster.get('graph_units'))
try:
indicator_value = str(metadata[title][year])
except KeyError:
# Handle missing metadata gracefully
logging.warning(f"Metadata for year {year} and title {title} is missing.")
indicator_value = "N/A"
computed_metadata = driver.compute_metadata(
raster['path'],
extra_metadata={
'indicator_value': str(metadata[title][year]),
'indicator_value': indicator_value,
'colormap': raster.get('palette').lower(),
'unit': unit.value[2]
})
Expand Down
Loading