Skip to content

Commit 2d92fb1

Browse files
authored
Change the gmt2gd() function when writing a 3D cube already in TRB. (#1729)
Apply a reshape to guarantee that array dime match declared width, height.
1 parent bdf8538 commit 2d92fb1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/gdal_utils.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ function gmt2gd(GI)
537537
end
538538
else
539539
if (GI.layout != "" && GI.layout[2] == 'R') # Here we may need to reshape the GI array to fit GDAL needs.
540-
indata = (height != size(GI, 1)) ? (n_dims == 2) ? reshape(GI.z, width, height) : reshape(GI.z, width, height, size(GI,3)) : GI.z
540+
indata = (height != size(GI, 1)) ? (n_dims == 2) ? reshape(GI.z, width, height) : reshape(GI.z, width, height, size(GI,3)) : reshape(GI.z, width, height, size(GI,3))
541541
else
542542
indata = GI.z
543543
end
@@ -886,6 +886,7 @@ function gdalwrite(cube::GItype, fname::AbstractString, v=nothing; dim_name::Str
886886
opts=["FORMAT=NC4", "COMPRESS=DEFLATE", "ZLEVEL=4"]
887887
(band_name != "") && append!(opts, [repeat("BAND_NAMES=$(band_name),", size(cube,3))])
888888
Gdal.destroy(Gdal.unsafe_copy(ds, filename=fname, driver=getdriver("netCDF"), options=opts))
889+
#write(ds, fname, driver=getdriver("netCDF"), options=opts)
889890
return nothing
890891
end
891892

0 commit comments

Comments
 (0)