Skip to content

Commit

Permalink
Merge pull request #45 from Simpleshell3/dependency
Browse files Browse the repository at this point in the history
Dependency
  • Loading branch information
Simpleshell3 authored Oct 6, 2024
2 parents c58733d + 2f48450 commit 4058e43
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
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

0 comments on commit 4058e43

Please sign in to comment.