returning subset of raster data via API
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 Thanks ..Tom |
|
Sean Gillies
Hi Tom, On Fri, Jan 17, 2020 at 8:35 AM Tom Kralidis <tom.kralidis@...> wrote:
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 |
|
(sorry, just getting back to this!) Thanks Sean. Indeed the MemoryFile strategy works as expected:
Are there any known issues with reading/subsetting, and writing back a NetCDF via MemoryFile? Traceback:
Versions:
Thanks ..Tom |
|
Sean Gillies
Hi Tom, On Mon, Aug 3, 2020 at 5:32 PM Tom Kralidis <tom.kralidis@...> wrote:
-- Sean Gillies |
|
Per https://gdal.org/user/virtual_file_systems.html#drivers-supporting-virtual-file-systems and confirmed by Even R, GDAL's NetCDF
driver cannot write to Thanks again for the clarifications. |
|
Sean Gillies
On Wed, Aug 5, 2020 at 5:41 AM Tom Kralidis <tom.kralidis@...> wrote:
You're welcome. It's unfortunate that we don't have a more informative message from GDAL that we can raise to users. "No such file or directory" is too opaque. Sean Gillies |
|