Skip to content

Commit 2135c3a

Browse files
committed
raster writer: skip empty timestaps
1 parent f361b12 commit 2135c3a

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

geoengine/raster.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ def spatial_partition(self) -> gety.SpatialPartition2D:
213213
def spatial_resolution(self) -> gety.SpatialResolution:
214214
return self.geo_transform.spatial_resolution()
215215

216+
def is_empty(self) -> bool:
217+
''' Returns true if the tile is empty'''
218+
num_pixels = self.size_x * self.size_y
219+
num_nulls = self.data.null_count
220+
return num_pixels == num_nulls
221+
216222
@staticmethod
217223
def from_ge_record_batch(record_batch: pa.RecordBatch) -> RasterTile2D:
218224
'''Create a RasterTile2D from an Arrow record batch recieved from the Geo Engine'''

geoengine/raster_workflow_rio_writer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def __create_new_dataset(self, query: QueryRectangle):
170170

171171
self.current_dataset = rio_dataset
172172

173-
async def query_and_write(self, query: QueryRectangle):
173+
async def query_and_write(self, query: QueryRectangle, skip_empty_times=True):
174174
''' Query the raster workflow and write the tiles to the dataset.'''
175175

176176
self.create_tiling_geo_transform_width_height(query)
@@ -182,6 +182,11 @@ async def query_and_write(self, query: QueryRectangle):
182182
if self.current_time != tile.time:
183183
self.close_current_dataset()
184184
self.current_time = tile.time
185+
186+
if tile.is_empty() and skip_empty_times:
187+
continue
188+
189+
if self.current_dataset is None:
185190
self.__create_new_dataset(query)
186191

187192
assert self.current_time == tile.time, "The time of the current dataset does not match the tile"

0 commit comments

Comments
 (0)