Metadata-Version: 2.1
Name: fake-geo-images
Version: 0.1.0
Summary: Fake geospatial images for unit tests
Home-page: https://github.com/up42/fake-geo-images
Author: UP42
Author-email: support@up42.com
License: MIT
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Requires-Python: >=3.6, <3.9
Description-Content-Type: text/markdown
Requires-Dist: numpy
Requires-Dist: rasterio
Requires-Dist: scipy
Requires-Dist: scikit-image
Requires-Dist: rio-cogeo

# 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
```bash
pip install fake-geo-images
```

## Usage

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

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

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
        )

    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

```




