Rasters.jl icon indicating copy to clipboard operation
Rasters.jl copied to clipboard

How do I write a RasterStack object to a GeoTIFF file using the Rasters package?

Open Ujjwal4CULS opened this issue 1 year ago • 1 comments
trafficstars

I want to create a GeoTIFF file with a screenshot of the 'rasstack' variable. Can someone assist with this? gmmp

Ujjwal4CULS avatar Dec 04 '23 09:12 Ujjwal4CULS

Is there a reason to use RasterStack specifically here? This is easier using RasterSeries as what you have is a series of rasters of identical size and type along a time dimension.

Something like this should work:

using Rasters, ArchGDAL
# a RasterSeries can be created from the list of files
series = RasterSeries(tif_filenames, Band(basename.(tiff_filenames))
# combine turns the slices of a RasterSeries into a single Raster we can write as one file.
raster = Rasters.combine(series, Band)
# Now we can write the geotiff
write("output_filename.tif", raster) 

Although I can test it without a MWE.

rafaqz avatar Dec 04 '23 09:12 rafaqz

Closed due to lack of reply from Op, not clear what to add here.

rafaqz avatar May 19 '24 20:05 rafaqz