[gdal-dev] Open Python3 bytes using gdal's Python bindings
Even Rouault
even.rouault at spatialys.com
Fri Dec 11 04:04:17 PST 2020
On jeudi 10 décembre 2020 19:06:35 CET Alex Riggs wrote:
> Hello all,
>
> First for some background. I have a service which receives protobuf
> messages, each message contains a bytes-encoded netcdf file. Currently, I
> write the netcdf to a temporary, on-disk file, which I then open with
> gdal.Open() to do some stuff to. Based on what I could discern, both the
> Open and OpenEx expect a string representing a file except in the case of
> "exotic drivers".
>
> My hope is to eliminate the need for that temporary file and instead read
> the bytes string directly. Is this possible?
If you're on Linux, then you could write the buffer in a /vsimem/ file
(gdal.FileFromMemBuffer('/vsimem/foo.nc', blob) ), and use the netCDF driver
on that file.
Actually we could likely remove the Linux-only restriction for the particular
case of /vsimem/ files but this isn't implemented currently in the driver.
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list