Skip to main content

Raster and shape tools

Project description

RasterToolkit

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

Setup

Install from github:

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

Getting Started

A typical raster_clip API usage scenario:

    from rastertoolkit import raster_clip

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

See the complete code in the WorldPop example (examples/worldpop)

A typical shape_subdivide API usage scenario:

    from rastertoolkit import shape_subdivide

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

See the complete code in the Shape Subdivision example (examples/shape_subdivide)

Developer Setup

  1. Clone or download this GitHub repo and navigate to the root directory.
    git clone git@github.com:InstituteforDiseaseModeling/RasterToolkit.git
    cd RasterToolkit
  1. Create a Python virtual environment (here useing uv; see https://astral.sh/uv/):
    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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rastertoolkit-0.4.1.tar.gz (18.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rastertoolkit-0.4.1-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file rastertoolkit-0.4.1.tar.gz.

File metadata

  • Download URL: rastertoolkit-0.4.1.tar.gz
  • Upload date:
  • Size: 18.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rastertoolkit-0.4.1.tar.gz
Algorithm Hash digest
SHA256 5bd61667923be0eb93779d04c0da80f253d36353d20df9c485d7463dafeb0eab
MD5 d5a6eb44cea091bf3c03479a203059b6
BLAKE2b-256 8ee27f20f93bb7f8766eaccc5b7e2e60d555e6e06efd5159cef753976646942e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rastertoolkit-0.4.1.tar.gz:

Publisher: publish_pypi.yml on InstituteforDiseaseModeling/RasterToolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rastertoolkit-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: rastertoolkit-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rastertoolkit-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d3f562302c0e52eca87c8d1c24506c678b2b10ef2af6b8cccc1010643a84bf77
MD5 40ee2f4d5b4deef0da1fa196fae67bc4
BLAKE2b-256 5eef8463cd0947b3835f523c64abb5aaf335cf31adffb617f60d057d32e104ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for rastertoolkit-0.4.1-py3-none-any.whl:

Publisher: publish_pypi.yml on InstituteforDiseaseModeling/RasterToolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page