(sorry, just getting back to this!)
Thanks Sean. Indeed the MemoryFile strategy works as expected:
import sys
import rasterio
from rasterio.io import MemoryFile
with rasterio.open(sys.argv[1]) as src:
with MemoryFile() as memfile:
profile = src.profile
with memfile.open(**profile) as dest:
dest.write(src.read())
Are there any known issues with reading/subsetting, and writing back a NetCDF via MemoryFile? Traceback:
(pygeoapi) (base) tomkralidis@aruba:~/Dev/pygeoapi/pygeoapi-tomkralidis$ python dd.py tests/data/CMIP5_rcp8.5_annual_abs_latlon1x1_PCP_pctl25_P1Y.nc
Traceback (most recent call last):
File "rasterio/_io.pyx", line 1135, in rasterio._io.DatasetWriterBase.__init__
File "rasterio/_err.pyx", line 205, in rasterio._err.exc_wrap_pointer
rasterio._err.CPLE_OpenFailedError: Unable to create netCDF file /vsimem/fa663a74-d548-494d-a2ab-880bdff831c4/fa663a74-d548-494d-a2ab-880bdff831c4. (Error code 2): No such file or directory .
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dd.py", line 9, in <module>
with memfile.open(**profile) as dest:
File "/Users/tomkralidis/opt/miniconda3/lib/python3.7/site-packages/rasterio/env.py", line 382, in wrapper
return f(*args, **kwds)
File "/Users/tomkralidis/opt/miniconda3/lib/python3.7/site-packages/rasterio/io.py", line 136, in open
nodata=nodata, sharing=sharing, **kwargs)
File "rasterio/_io.pyx", line 1139, in rasterio._io.DatasetWriterBase.__init__
rasterio.errors.RasterioIOError: Unable to create netCDF file /vsimem/fa663a74-d548-494d-a2ab-880bdff831c4/fa663a74-d548-494d-a2ab-880bdff831c4. (Error code 2): No such file or directory .
Versions:
>>> import rasterio
>>> rasterio.__version__
'1.1.5'
>>> rasterio.gdal_version()
'3.0.4'
Thanks
..Tom