Help exporting a geotiff with a transparent background
Mostra commenti meno recenti
I am working on a project where I want to export two geotiffs, the first is basically a georeferenced screenshot of data in a geoaxes with the satellite base map. I have this one working fine. The second one that I want to export is just the data, I have three datasets im trying to export, lat/long points, depth data (im currently plotting this with geoscatter) and contour lines. No matter what I try all im exporting is a black square and no data. Below is my code at just exporting the data with a transparent background.
I thought no background would be easier but I guess not, im having a tough time with it. Also, just an FYI, this is a small part of a very large project im working on so all of the variable names are brought in through other functions.
res = 0.00005;
lat_v = min(lat):res:max(lat);
long_v = min(long):res:max(long);
[long_grid,lat_grid] = meshgrid(long_v,lat_v);
depth_grid = griddata(long,lat,depth,long_grid,lat_grid,'natural');
% C = contourc(lonv,latv,depth_grid,5);
R = georefcells([min(lat_v) max(lat_v)], [min(long_v) max(long_v)], size(depth_grid));
R.ColumnsStartFrom = 'north';
geotiffwrite(output_file, depth_grid, R);
2 Commenti
Walter Roberson
il 6 Mar 2026
Small note:
Because of the way the variables are constructed, min(lat_v) is the same as lat_v(1) and max(lat_v) is the same as lat_v(end) . Likewise for long_v. So you could
R = georefcells(lat_v([1 end]), long_v([1 end]), size(depth_grid));
dpb
il 7 Mar 2026
geotiffwrite doesn't have any way to code transparency; you'll have to fix up the image data itself.
Try setting the non-data points in the image to NaN after geoscatter and countourc
You didn't attach the image or data for anybody to do anything with -- it's too late by the time you get to this point.
Risposte (0)
Categorie
Scopri di più su Surface and Mesh Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!