Skip to content

Commit

Permalink
Test error when getting band_names. #987
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileSonneveld committed Jan 8, 2025
1 parent c0a949a commit f0f5342
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
21 changes: 21 additions & 0 deletions tests/data/geometries/small_polygon.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[0.0, 0.0],
[0.0001, 0.0],
[0.0001, 1.0],
[0.0, 1.0],
[0.0, 0.0]
]
]
}
}
]
}
3 changes: 2 additions & 1 deletion tests/datacube_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest
import pytz

from openeogeotrellis.geopysparkdatacube import GeopysparkDataCube
from openeogeotrellis.service_registry import InMemoryServiceRegistry

TILE_SIZE = 16 # multiple of 16 as this is used for the GeoTIFF tile size as well and mandated by its spec
Expand Down Expand Up @@ -133,7 +134,7 @@ def layer_with_two_bands_and_one_date():


@pytest.fixture
def imagecollection_with_two_bands_and_one_date(request):
def imagecollection_with_two_bands_and_one_date(request) -> GeopysparkDataCube:
import geopyspark as gps
from openeogeotrellis.geopysparkdatacube import GeopysparkDataCube, GeopysparkCubeMetadata
geopyspark_layer = layer_with_two_bands_and_one_date()
Expand Down
14 changes: 14 additions & 0 deletions tests/test_timeseries.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
import json
from pathlib import Path
from tempfile import NamedTemporaryFile
from unittest import TestCase

Expand Down Expand Up @@ -242,6 +243,19 @@ def test_aggregate_spatial_last_polygon_empty(get_regions, imagecollection_with_
}


def test_aggregate_spatial_small_polygon(imagecollection_with_two_bands_and_one_date):
regions = DriverVectorCube.from_fiona([str(get_test_data_file("geometries/small_polygon.geojson"))], None, {})

result = imagecollection_with_two_bands_and_one_date.aggregate_spatial(
regions, {"mean1": {"process_id": "mean", "arguments": {"data": {"from_parameter": "data"}}, "result": True}}
)
assert isinstance(result, AggregatePolygonResultCSV)

spatial_result = AggregatePolygonResult(result.get_data(), regions=regions)
filename = spatial_result.to_geoparquet()
assert Path(filename).exists()


def test_zonal_statistics_median_datacube(imagecollection_with_two_bands_and_three_dates):

polygon = Polygon(shell=[
Expand Down

0 comments on commit f0f5342

Please sign in to comment.