issues: 312203596
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
312203596 | MDU6SXNzdWUzMTIyMDM1OTY= | 2042 | Anyone working on a to_tiff? Alternatively, how do you write an xarray to a geotiff? | 601025 | closed | 0 | 31 | 2018-04-07T12:43:41Z | 2022-04-09T03:14:41Z | 2022-04-09T01:19:10Z | NONE | Matthew Rocklin wrote a gist https://gist.github.com/mrocklin/3df315e93d4bdeccf76db93caca2a9bd to demonstrate using XArray to read tiled GeoTIFF datasets, but I am still confused as to how to write them to a GeoTIFF. I can easily create a tiff with "rasterio.open(out, 'w', **src.profile)", but the following does not seem like the best/cleanest way to do this: ``` ds = xr.open_rasterio('myfile.tif', chunks={'band': 1, 'x': 2048, 'y': 2048}) with rasterio.open('myfile.tif', 'r') as src: with rasterio.open('new_myfile.tif', 'w', **src.profile) as dst: for i in range(1, src.count + 1): dst.write(ds.variable.data[i-1].compute(), i) ``` Also, if the profile and tags were propagated through open_rasterio, then the second open would not be necessary and would be generally useful. |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2042/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |