Re: returning subset of raster data via API

Sean Gillies

Hi Tom,

On Fri, Jan 17, 2020 at 8:35 AM Tom Kralidis <tom.kralidis@...> wrote:

Hi all: as part of working on OGC API - Coverages support in pygeoapi, I'm writing the equivalent of what WCS GetCoverage would do; that is, clip by bbox and subset by bands if requested.

An initial implementation can be found in this branch.

At the moment, the data is returned as JSON-ified ndarrays. I would like to return the data in its native format. What would be a general approach here? Would one use a MemoryFile, write to it, and then read it back to the caller?


When you say that you want to return the data in its native format, do you mean a stream of bytes that contain, for example, a GeoTIFF? The MemoryFile class would serve you well in that case if you wanted to avoid writing to disk, or one of Python's temporary file objects would do just as well if you didn't mind or wanted a temp file on disk. You would be limited to single-file formats if you used MemoryFile, our abstraction doesn't cover multiple files. It seems to me that there would be a related problem for multiple files on the serialization end, whether you used MemoryFile or not: how do you put multiple files in a single stream of bytes?

Sean Gillies

Join to automatically receive all group messages.