Skip to main content

fake-geo-images

A module to programmatically create geotiff images which can be used for unit tests.

The underlying idea is that in order to write unit tests for geospatial image processsing algorithms, it is necessary to have an actual input image file or array. Organising these test images becomes a chore over time, they should not be stored in git as they are large binary data and when stored outside, there always is the danger that they are not updated according to changes in the code repo.

fake-geo-images provides a solution to the problem by providing simple code that allows to create geospatial images (so far geotiffs) in a parameterised way.

Install package

pip install fake-geo-images

Run tests

pytest

Usage

In the following an example unit test for a hypothetical NDVI function.

import numpy as np
import rasterio as rio
from pathlib import Path

from rasterio.transform import from_origin
from my_image_processing import ndvi
from fake_geo_images.fakegeoimages import FakeGeoImage

def test_ndvi():
    """
    A unit test if an NDVI method works in general
    """
    # Create 4-band image simulating RGBN as needed for NDVI
    test_image, _ = FakeGeoImage(
        300,
        150,
        4,
        "uint16",
        out_dir=Path("/tmp"),
        crs=4326,
        nodata=0,
        nodata_fill=3,
        cog=False,
    ).create(seed=42, transform=from_origin(13.428596, 52.494384, 0.000006, 0.000006))

    ndvi_image = ndvi(test_image)

    with rio.open(str(ndvi_image)) as src:
        ndvi_array = src.read()
        # NDVI only has one band of same size as input bands
        assert ndvi_array.shape == (1, 300, 150)
        # NDVI has float values between -1 and 1
        assert ndvi_array.dtype == np.float
        assert ndvi_array.min >= -1
        assert ndvi_array.max <= 1

Release files for fake-geo-images 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fake-geo-images 0.1.5
File Size Uploaded
fake-geo-images-0.1.5.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fake-geo-images 0.1.5
File Interpreter ABI Platform
fake_geo_images-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 15.4 kB

Release files / fake-geo-images-0.1.5.tar.gz

Download URL fake-geo-images-0.1.5.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9ec116f869c5d44790aa8e533606ef24e2e10409201fc5c82586e05671e9e994
BLAKE2b-256 checksum
How to use checksums
ee18a3c7179ae2a09de79805997c687a3b10a8431d37ff4f91757728913189e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / fake_geo_images-0.1.5-py3-none-any.whl

Download URL fake_geo_images-0.1.5-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df58624634ea4a94aa0160624904b646b5d1dcf5f2d6576832fcaac59b22b90b
BLAKE2b-256 checksum
How to use checksums
d985fc0a2a44fb5e915372bcd92dcf07e8be5bb81e7382435dee36afcf36006c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page