Help exporting a geotiff with a transparent background
Show older comments
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);
1 Comment
Walter Roberson
18 minutes ago
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));
Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!