corteva / rioxarray

geospatial xarray extension powered by rasterio
https://corteva.github.io/rioxarray
Other
518 stars 82 forks source link

DOC: add section on writing files in docs #584

Open raybellwaves opened 2 years ago

raybellwaves commented 2 years ago

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

snowman2 commented 2 years ago

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 commented 2 years ago

Documentation on writing to a raster is welcome 👍