Skip to content

Commit eb7d7a5

Browse files
committed
Issue #100: simplify ImageCollectionClient.download
and remove `download` from `ImageCollection` base class. Also drop pre-0.4 support from download (issue #72)
1 parent 4fc8177 commit eb7d7a5

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

openeo/imagecollection.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,10 +541,6 @@ def tiled_viewing_service(self,**kwargs) -> Dict:
541541
"""
542542
pass
543543

544-
def download(self, outputfile: str, **format_options):
545-
"""Extracts a binary raster from this image collection."""
546-
pass
547-
548544
def send_job(self) -> Job:
549545
"""Sends the current process to the backend, for batch processing.
550546

openeo/rest/imagecollectionclient.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -941,34 +941,21 @@ def graph_add_aggregate_process(graph) -> 'ImageCollection':
941941

942942
return graph_add_aggregate_process(self)
943943

944-
def save_result(self, format: str, options: dict = None):
944+
def save_result(self, format: str = "GTIFF", options: dict = None):
945945
return self.graph_add_process(
946946
process_id="save_result",
947947
args={
948948
"data": {"from_node": self.node_id},
949949
"format": format,
950-
"options": options
950+
"options": options or {}
951951
}
952952
)
953953

954-
def download(self, outputfile: str, **format_options) -> str:
955-
"""Extracts a geotiff from this image collection."""
956-
957-
if self._api_version.at_least('0.4.0'):
958-
args = {
959-
'data': {'from_node': self.node_id},
960-
'options': format_options
961-
}
962-
if 'format' in format_options:
963-
args['format'] = format_options.pop('format')
964-
else:
965-
raise ValueError("Please use the 'format' keyword argument to specify the output format. Use openeo.connection.Connection#list_file_types to retrieve available ouput formats for this backend.")
966-
newcollection = self.graph_add_process("save_result",args)
967-
newcollection.graph[newcollection.node_id]["result"] = True
968-
return self.session.download(newcollection.graph, outputfile)
969-
else:
970-
self.graph[self.node_id]["result"] = True
971-
return self.session.download(self.graph, outputfile)
954+
def download(self, outputfile: str, format: str = "GTIFF", options: dict = None):
955+
"""Download image collection, e.g. as GeoTIFF."""
956+
newcollection = self.save_result(format=format, options=options)
957+
newcollection.graph[newcollection.node_id]["result"] = True
958+
return self.session.download(newcollection.graph, outputfile)
972959

973960
def tiled_viewing_service(self,**kwargs) -> Dict:
974961
newbuilder = self.builder.copy()

0 commit comments

Comments
 (0)