Skip to content
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ghcr.io/devcontainers/features/git:1": {}
},
//"onCreateCommand": "apt-get update && apt-get install -y python3-pip pipenv",
"postCreateCommand": "pipenv --python 3 && pipenv run pip install -r requirements.txt",
"postCreateCommand": "pipenv --python 3 && pipenv run pip install -e .",

//"postCreateCommand": "id",
"customizations": {
Expand Down
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ RUN apt-get update && \

WORKDIR /app

COPY requirements.txt .
RUN pipenv --python 3 && pipenv install -r requirements.txt

COPY . .
RUN pipenv --python 3 && pipenv run pip install -e .

RUN chmod +x cbsurge.sh

CMD [ "./cbsurge.sh", "--help"]
CMD [ "pipenv", "run", "rapida", "--help"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test:
@echo "------------------------------------------------------------------"
@echo "Execute test cases"
@echo "------------------------------------------------------------------"
pipenv run python -m pytest cbsurge/stats
pipenv run python -m pytest tests

build:
@echo
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@ A repo to hold python tools that facilitate the assessment of natural hazards ov

## Usage

Install dependencies to virtual environment as below.
Install the project with dependencies to virtual environment as below.

```shell
pipenv install -r requirements.txt
pipenv run pip install -e .
```

Then, run the below command to show help menu.

```shell
pipenv run python -m cbsurge.cli --help
pipenv run rapida --help
```

To uninstall the project from Python environment, execute the following command.

```shell
pipenv run pip uninstall geo-cb-surge
```

## Admin
Expand All @@ -22,13 +28,13 @@ pipenv run python -m cbsurge.cli --help
- OSM

```shell
pipenv run python -m cbsurge.cli admin osm --help
pipenv run rapida admin osm --help
```

- ocha

```shell
pipenv run python -m cbsurge.cli admin ocha --help
pipenv run rapida admin ocha --help
```

## Run test
Expand Down Expand Up @@ -59,5 +65,5 @@ make down

```shell
make shell
./cbsurge.sh --help # run CLI in shell on docker container
pipenv run rapida --help # run CLI in shell on docker container
```
3 changes: 0 additions & 3 deletions cbsurge.sh

This file was deleted.

4 changes: 2 additions & 2 deletions cbsurge/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def osm(bbox=None,admin_level=None, osm_level=None, clip=False, h3id_precision=7

To save the result as a file, for instance, the following command can be executed to extract admin 0 data for Rwanda and Burundi as GeoJSON file:

python -m cbsurge.cli admin osm -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > osm.geojson
rapida admin osm -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > osm.geojson
"""
silence_httpx_az()
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
Expand Down Expand Up @@ -156,7 +156,7 @@ def ocha(bbox=None,admin_level=None, clip=False, h3id_precision=7, debug=False)

To save the result as a file, for instance, the following command can be executed to extract admin 0 data for Rwanda and Burundi as GeoJSON file:

python -m cbsurge.cli admin ocha -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > ocha.geojson
rapida admin ocha -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > ocha.geojson
"""
silence_httpx_az()
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
Expand Down
4 changes: 2 additions & 2 deletions cbsurge/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def compute(

Usage: \n
The below command provides how to use the command to compute zonal statistics.\n
python -m cbsurge.cli stats compute --help
rapida stats compute --help

Example: \n
python -m cbsurge.cli stats compute ./cbsurge/stats/tests/assets/admin2.geojson ./cbsurge/stats/tests/assets/admin2_stats.fgb -r ./cbsurge/stats/tests/assets/rwa_m_5_2020_constrained_UNadj.tif -r ./cbsurge/stats/tests/assets/rwa_f_5_2020_constrained_UNadj.tif -o sum -c male_5_sum -c female_5_sum
rapida stats compute ./cbsurge/stats/tests/assets/admin2.geojson ./cbsurge/stats/tests/assets/admin2_stats.fgb -r ./cbsurge/stats/tests/assets/rwa_m_5_2020_constrained_UNadj.tif -r ./cbsurge/stats/tests/assets/rwa_f_5_2020_constrained_UNadj.tif -o sum -c male_5_sum -c female_5_sum
"""
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
with ZonalStats(input_file, target_srid=54009) as st:
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ services:
command: "pipenv run python -m cbsurge.cli --help"
volumes:
- ./Makefile:/app/Makefile
- ./cbsurge:/app/cbsurge # mount app folder to container
- ./cbsurge:/app/cbsurge # mount app folder to container
- ./tests:/app/tests
69 changes: 69 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[project]
name = "geo-cb-surge"
version = "0.0.1"
description = "python tools that facilitate the assessment of natural hazards over various domains like population, landuse, infrastructure, etc"
requires-python = ">=3.12"
authors = [
{ name = 'Ioan Ferencik'},
{ name = 'Joseph Thuha'},
{ name = 'Jin Igarashi'},
{ name = "United Nations Development Programme", email = "[email protected]" }
]
readme = "README.md"
dependencies = [
"httpx",
"osm2geojson",
"shapely",
"h3",
"tqdm",
"GDAL==3.10.0",
"azure-storage-blob",
"overturemaps",
"async",
"aiofiles",
"aiohttp",
"azure-storage-blob",
"asyncclick",
"rio-cogeo",
"exactextract",
"pycountry",
"click",
"pyarrow",
"azure-core",
"rasterio",
"geopandas",
"pytest"
]

[project.scripts]
rapida = "cbsurge.cli:cli"

[tool.setuptools]
py-modules = ["cbsurge"]

[project.urls]
Homepage = "https://github.com/UNDP-Data/geo-cb-surge"
Documentation = "https://github.com/UNDP-Data/geo-cb-surge"
Repository = "https://github.com:UNDP-Data/geo-cb-surge.git"
Issues = "https://github.com/UNDP-Data/geo-cb-surge/issues"
#Changelog = "https://github.com/UNDP-Data/geo-cb-surge/blob/master/CHANGELOG.md"

[tool.hatch.build.targets.wheel]
packages = ["cbsurge"]

[tool.hatch.build.targets.sdist]
exclude = [
".devcontainer",
".github",
".dockerignore",
"docker-compose.yml",
"Dockerfile",
".gitignore",
".pre-commit-config.yaml",
"tests",
"Makefile"
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
22 changes: 0 additions & 22 deletions requirements.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
from cbsurge.stats.ZonalStats import ZonalStats

TEST_DIR = "./cbsurge/stats/tests"
TEST_DIR = "./tests/cbsurge/stats"

def get_test_path(relative_path):
"""Helper function to generate absolute paths for test assets."""
Expand Down
Loading