rioxarray icon indicating copy to clipboard operation
rioxarray copied to clipboard

DOC: add section on writing files in docs

Open raybellwaves opened this issue 1 year ago • 2 comments

Currently there is https://corteva.github.io/rioxarray/stable/getting_started/getting_started.html#reading-files

I would propose to amend the above for a quick example of reading from cloud storage e.g. xds = xarray.open_dataset("s3://bucket/my.tif", engine="rasterio")

It would be good to have a section of writing files with two example. One, writing to disk da.rio.to_raster(out.tif) and one writing to cloud storage.

I couldn't find any good examples of best practices of writing to cloud storage within https://github.com/corteva/rioxarray/discussions/204

I have opted to use

with fsspec.open(f"s3://bucket/my.tif", "wb") as f:
    da.rio.to_raster(f, driver='GTiff')

If that is considered as best practice i'll be happy to make a PR

raybellwaves avatar Sep 28 '22 02:09 raybellwaves

You should be able to write to cloud storage by passing the S3 URL directly into to_raster (https://gdal.org/user/virtual_file_systems.html#vsis3-aws-s3-files). I am not sure if the fsspec version works.

snowman2 avatar Sep 28 '22 12:09 snowman2

Documentation on writing to a raster is welcome 👍

snowman2 avatar Sep 28 '22 12:09 snowman2