Skip to content

Commit

Permalink
fix tile-index use with geometry (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmaai authored and vnewey committed Apr 4, 2018
1 parent d51369f commit fb35694
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 8 additions & 2 deletions datacube_stats/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,14 @@ def from_configuration_file(cls, config, index=None, tile_indexes=None, output_l
:return: read to run StatsApp
"""
input_region = config.get('input_region')
if tile_indexes and not input_region:
input_region = {'tiles': tile_indexes}

if tile_indexes is not None:
if input_region is None:
input_region = {'tiles': tile_indexes}
elif 'geometry' in input_region:
input_region.update({'tiles': tile_indexes})
elif 'from_file' not in input_region:
input_region = {'tiles': tile_indexes}

if year is not None:
if 'date_ranges' not in config:
Expand Down
12 changes: 5 additions & 7 deletions datacube_stats/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,17 @@ def select_task_generator(input_region, storage, filter_product):
_LOG.info('No input_region specified. Generating full available spatial region, gridded files.')
return GriddedTaskGenerator(storage)

elif 'geometry' in input_region: # Larger spatial region
# A large, multi-tile input region, specified as geojson. Output will be individual tiles.
geometry = Geometry(input_region['geometry'], CRS('EPSG:4326')) # GeoJSON is always 4326
return GriddedTaskGenerator(storage, geopolygon=geometry, tile_indexes=input_region.get('tiles'))

elif 'tile' in input_region: # For one tile
return GriddedTaskGenerator(storage, tile_indexes=[input_region['tile']])

elif 'tiles' in input_region: # List of tiles
return GriddedTaskGenerator(storage, tile_indexes=input_region['tiles'])

elif 'geometry' in input_region: # Larger spatial region
# A large, multi-tile input region, specified as geojson. Output will be individual tiles.
_LOG.info('Found geojson `input_region`, outputing tiles.')

geometry = Geometry(input_region['geometry'], CRS('EPSG:4326')) # GeoJSON is always 4326
return GriddedTaskGenerator(storage, geopolygon=geometry)

elif 'from_file' in input_region:
_LOG.info('Input spatial region specified by file: %s', input_region['from_file'])

Expand Down

0 comments on commit fb35694

Please sign in to comment.