GDAL - Write KMZ file with transparency

I’m trying to save a .kmz file from a dataset representing a DEM of an area stored in a GeoTiff file.

My code is reading the DEM, transforming the CRS to UTM, and defining a subset based on coordinates. On this subset I did some computation based on the DEM altitude.

I’d like to save the result in a kmz file to be opened in Google Earth using Julia.

What I’ve tried up to now is to use ArchGDAL together with Rasters.jl. However the results is not what I wanted, I’m still missing the transparency for the missing values.
I’ve found a similar question, but it didn’t explain how he fixed.

The gdal command that should do the job is

gdalwarp -srcnodata <in> -dstnodata <out> -crop_to_cutline -cutline INPUT.shp INPUT.tif OUTPUT.tif

I’ve tried to replicate it with Rasters.jl, having defined the the cropline as a GeoJSON

A = Raster(dem_file)
flags = Dict(
        "-srcnodata"=> NaN, "-dstnodata" =>0, 
        "-crop_to_cutline" => "", "-cutline" =>"./shape.json",
        )
B = warp(A, flags)   
write("out.kmz",B)

The subset I’m working on in Julia is a structure with the same dimensions of the original DEM, but to define the subset I have set all the values out of the bounds to NaN. This is the subset plotted in Julia with the red crosses represetning the 4 points in Polygon of the cutline

Subset of DEM plotted in Julia

This is the result of the gdal_warp function

Result of the cropping

What I can see is that gdal_warp is cropping correctly the original DEM file but it is not considering the nodata field, and it is mapping it to a the black color. I’ve tried changing the values but it seems to not affect the output.

You may wang to teu GMT’s grd2kml grd2kml