-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create a single RasterStack from multiple multi-layer TIFF files with different extents while preserving the original band names.? #585
Comments
This is too much code for a MWE and not runnable, so its hard to see what you want to do, try to post something short and runnable next time. But, I'll guess: rast = Raster(rand(10, 10, 5), (X(), Y(), Band([:a, :b, :c, :d, :e])))
st = RasterStack(rast; layersfrom=Band) Which gives you a stack where the band lookup values are the layer names: julia> st = RasterStack(rast; layersfrom=Band)
RasterStack with dimensions: X, Y
and 5 layers:
:a Float64 dims: X, Y (10×10)
:b Float64 dims: X, Y (10×10)
:c Float64 dims: X, Y (10×10)
:d Float64 dims: X, Y (10×10)
:e Float64 dims: X, Y (10×10) If your bands are just numbers the stack layers will be call If you want to combine multiple multiband rasters into a single stack, you can just |
I updated the code. |
Ok, well exactly what I said then :) |
Here, "rasters[1]...rasters[n]" represents multilayered band data with different extents. How can I stack these into a single raster dataset? |
A RasterStack has a fixed extent. You can |
The commands
|
You need to make stacks from each one separately, then use A RasterStack doesn't use |
"merge" is also not working.
"titu" should have 118 layers, but it only has 91 layers. |
Where is `layersfrom` ?
…On Sun, 24 Dec 2023, 13:04 Jigyasu4indp, ***@***.***> wrote:
"merge" is also not working.
>a = RasterStack(resampled_rasters[1])
RasterStack with dimensions:
X Projected{Float64} LinRange{Float64}(28.9456, 114.617, 31732) ForwardOrdered Regular Intervals{Start} crs: WellKnownText,
Y Projected{Float64} LinRange{Float64}(-13.3192, 42.4047, 20640) ForwardOrdered Regular Intervals{Start} crs: WellKnownText,
Band Categorical{String} String[2018-05-31, 2018-05-30, …, 2018-11-02, 2018-11-01] Unordered
and 1 layer:
:layer1 Float32 dims: X, Y, Band (31732×20640×91)
with metadata Metadata{Rasters.GDALsource} of Dict{String, Any} with 4 entries:
"units" => ""
"offset" => 0.0
"filepath" => "./sentinel_2018_daily_rast.tif"
"scale" => 1.0
>b = RasterStack(resampled_rasters[b])
RasterStack with dimensions:
X Projected{Float64} LinRange{Float64}(28.9456, 114.617, 31732) ForwardOrdered Regular Intervals{Start} crs: WellKnownText,
Y Projected{Float64} LinRange{Float64}(-13.3192, 42.4047, 20640) ForwardOrdered Regular Intervals{Start} crs: WellKnownText,
Band Categorical{String} String[2018-05-31, 2018-05-30, …, 2018-11-02, 2018-11-01] Unordered
and 1 layer:
:layer1 Float32 dims: X, Y, Band (31732×20640×91)
with metadata Metadata{Rasters.GDALsource} of Dict{String, Any} with 4 entries:
"units" => ""
"offset" => 0.0
"filepath" => "./sentinel_2018_daily_rast.tif"
"scale" => 1.0
> titu = merge(a, b)
RasterStack with dimensions:
X Projected{Float64} LinRange{Float64}(28.9456, 114.617, 31732) ForwardOrdered Regular Intervals{Start} crs: WellKnownText,
Y Projected{Float64} LinRange{Float64}(-13.3192, 42.4047, 20640) ForwardOrdered Regular Intervals{Start} crs: WellKnownText,
Band Categorical{String} String[2018-05-31, 2018-05-30, …, 2018-11-02, 2018-11-01] Unordered
and 1 layer:
:layer1 Float32 dims: X, Y, Band (31732×20640×91)
with metadata Metadata{Rasters.GDALsource} of Dict{String, Any} with 4 entries:
"units" => ""
"offset" => 0.0
"filepath" => "./sentinel_2018_daily_rast.tif"
"scale" => 1.0
"titu" should have 118 layers, but it only has 91 layers.
—
Reply to this email directly, view it on GitHub
<#585 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AATKU6LN6TOCQ37QFCP3CDLYLAK4BAVCNFSM6AAAAABBAUISTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRYGUYDANJSGA>
.
You are receiving this because you commented.Message ID: <rafaqz/Rasters.
***@***.***>
|
Thanks, it's working! |
|
One day... This is just one of very many packages I maintain and try to share with others. R spatial data is decades old. In Julia we are just putting things together now. There is no possibility of our docs matching the R docs in the next five years, let alone soon - unless a whole lot more people start helping. (please dont make requests like 2 again - its not reasonable. This is a free package and I'm helping you for free - are you going to help me in some way in return?) With You are using Why don't you change the names when they are the Band dimension of a |
How to make a RasterStack of rasters while preserving the band names of tif_files.
The text was updated successfully, but these errors were encountered: