Commit 9b08ce84 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Added docstring to GeoArray.tiles() and corresponding tests.

parent cc0c482d
......@@ -4,6 +4,7 @@ import os
import warnings
from importlib import util
from collections import OrderedDict
from typing import Generator # noqa F401 # flake8 issue
import numpy as np
from matplotlib import pyplot as plt
......@@ -1324,10 +1325,12 @@ class GeoArray(object):
self.footprint_poly = self.footprint_poly.intersection(
def tiles(self, tilesize=(100, 100)):
# type: (tuple) -> Generator
"""Get tiles of the full dataset in the given tile size.
:param tilesize:
:param tilesize: target size of the tiles (rows, columns)
NOTE: If rows or columns are None, all rows/columns are returned
:return: Generator with elements like: ((rowStart, rowEnd), (colStart, colEnd),tiledata
bounds_alltiles = get_array_tilebounds(self.shape, tilesize)
......@@ -34,6 +34,7 @@ import time
import unittest
from unittest import TestLoader
import matplotlib
from typing import Generator
# Imports regarding the created python module.
from py_tools_ds.geo.vector import geometry
......@@ -418,6 +419,13 @@ class Test_GeoarrayFunctions(unittest.TestCase):
self.assertIsInstance(self.testtiff.metadata, geopandas.GeoDataFrame)
def test_tiles(self):
tiles = self.testtiff.tiles(tilesize=(50, 50))
self.assertIsInstance(tiles, Generator)
for ((rS, rE), (cS, cE)), tile in tiles:
self.assertTrue(np.array_equal(tile, self.testtiff[rS: rE + 1, cS: cE + 1]))
def test_SaveTiffToDisk(self):
Testing the function: save,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment