On smaller arrays I would do:
\nfrom rioxarray import merge\n\narrays = [first_array, second_array]\nmerged_array = merge.merge_arrays(arrays, nodata=0)\n
However... on my big datasets, that doesn't work. I encounter pretty quickly a MemoryError
.
For now, the only solution I found is:
\nfirst_array.to_raster(\"some_file.tif\")
rasterio.merge
to directly merge the files on disk:from pathlib import Path\nfrom rasterio import merge\n\nrasters_to_merge = [rasterio.open(filename) for filename in filenames]\ndestination = Path(\"merged_raster.tif\")\nmerge.merge(rasters_to_merge, dst_path=destination)\n\n
My question (finally), is there a native way in xarray to perform the same operations? Thanks
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"\n\nis there a native way in xarray to perform the same operations?
\n
Not in a memory efficient way presently. The solution of writing to disk is a great way for you to merge larger datasets in a memory efficient way.
","upvoteCount":1,"url":"https://github.com/corteva/rioxarray/discussions/827#discussioncomment-11189893"}}}-
Hello, This is how I load each dataarray:
On smaller arrays I would do:
However... on my big datasets, that doesn't work. I encounter pretty quickly a For now, the only solution I found is:
My question (finally), is there a native way in xarray to perform the same operations? Thanks |
Beta Was this translation helpful? Give feedback.
-
Not in a memory efficient way presently. The solution of writing to disk is a great way for you to merge larger datasets in a memory efficient way. |
Beta Was this translation helpful? Give feedback.
Not in a memory efficient way presently. The solution of writing to disk is a great way for you to merge larger datasets in a memory efficient way.