Skip to content

Commit

Permalink
migrate raster size from list to dict. natcap#58
Browse files Browse the repository at this point in the history
  • Loading branch information
davemfish committed Jan 9, 2025
1 parent 84d2bca commit b9633b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/geometamaker/geometamaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ def describe_raster(source_dataset_path, scheme):
description['data_model'] = models.RasterSchema(
bands=bands,
pixel_size=info['pixel_size'],
raster_size=info['raster_size'])
raster_size={'width': info['raster_size'][0],
'height': info['raster_size'][1]})
# Some values of raster info are numpy types, which the
# yaml dumper doesn't know how to represent.
bbox = models.BoundingBox(*[float(x) for x in info['bounding_box']])
Expand Down
8 changes: 7 additions & 1 deletion src/geometamaker/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ class RasterSchema(Parent):

bands: List[BandSchema]
pixel_size: list
raster_size: list
raster_size: dict | list

def model_post_init(self, __context):
# Migrate from previous model where we stored this as a list
if isinstance(self.raster_size, list):
self.raster_size = {'width': self.raster_size[0],
'height': self.raster_size[1]}


class BaseMetadata(Parent):
Expand Down

0 comments on commit b9633b3

Please sign in to comment.