Skip to content

Commit

Permalink
Issue #100: simplify ImageCollectionClient.download
Browse files Browse the repository at this point in the history
and remove `download` from `ImageCollection` base class.
Also drop pre-0.4 support from download (issue #72)
  • Loading branch information
soxofaan committed Nov 21, 2019
1 parent 4fc8177 commit eb7d7a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
4 changes: 0 additions & 4 deletions openeo/imagecollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,6 @@ def tiled_viewing_service(self,**kwargs) -> Dict:
"""
pass

def download(self, outputfile: str, **format_options):
"""Extracts a binary raster from this image collection."""
pass

def send_job(self) -> Job:
"""Sends the current process to the backend, for batch processing.
Expand Down
27 changes: 7 additions & 20 deletions openeo/rest/imagecollectionclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,34 +941,21 @@ def graph_add_aggregate_process(graph) -> 'ImageCollection':

return graph_add_aggregate_process(self)

def save_result(self, format: str, options: dict = None):
def save_result(self, format: str = "GTIFF", options: dict = None):
return self.graph_add_process(
process_id="save_result",
args={
"data": {"from_node": self.node_id},
"format": format,
"options": options
"options": options or {}
}
)

def download(self, outputfile: str, **format_options) -> str:
"""Extracts a geotiff from this image collection."""

if self._api_version.at_least('0.4.0'):
args = {
'data': {'from_node': self.node_id},
'options': format_options
}
if 'format' in format_options:
args['format'] = format_options.pop('format')
else:
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.")
newcollection = self.graph_add_process("save_result",args)
newcollection.graph[newcollection.node_id]["result"] = True
return self.session.download(newcollection.graph, outputfile)
else:
self.graph[self.node_id]["result"] = True
return self.session.download(self.graph, outputfile)
def download(self, outputfile: str, format: str = "GTIFF", options: dict = None):
"""Download image collection, e.g. as GeoTIFF."""
newcollection = self.save_result(format=format, options=options)
newcollection.graph[newcollection.node_id]["result"] = True
return self.session.download(newcollection.graph, outputfile)

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

0 comments on commit eb7d7a5

Please sign in to comment.