Skip to content

InstituteforDiseaseModeling/RasterTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RasterTools

A Python package for processing rasters with minimal dependencies. For example, with rastertools you can extract populations corresponding to an administrative shapefile from a raster file.

Setup

Pip install from github:

pip install git+https://github.com/InstituteforDiseaseModeling/RasterTools.git

Getting Started

A typical raster_clip API usage scenario looks like this:

from rastertools import raster_clip

# Clipping raster with shapes
pop_dict = raster_clip(raster_file, shape_file)

See the complete code in the WorldPop example.

A typical shape_subdivide API usage scenario looks like this:

from rastertools import shape_subdivide

# Create shape subdivision layer
subdiv_stem = shape_subdivide(shape_stem=shape_file)

See the complete code in the Shape Subdivision example.

Developer Setup

  1. Clone or download this GitHub repo and cd to the repo root.:

    git clone git@github.com:InstituteforDiseaseModeling/RasterTools.git
    cd RasterTools
    

#. Create a Python virtual environment using the preferred tool (here we use [uv](curl -LsSf https://astral.sh/uv/install.sh | sh )).:

uv venv --python 3.10
source .venv/bin/activate
  1. Install this package in editable mode (this also installs all the requirements).:

    uv pip install -e .
    

Running Tests

Functional tests:

Install additional packages (like pytest):

uv pip install -r requirements-test.txt

Run pytest command:

# Run unit tests (recommended during development)
pytest -m unit -v

# Run test for a specific module, for example
pytest tests/test_shape.py -v     # run shape unit tests
pytest tests/test_download.py -v  # run GDx download tests

# All tests (before a commit or merging a PR)
pytest -v

About

Python scripts for working with shapefiles and rasterized population data

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages