% First stab at creating an indexed-face-set from a netcdf file % Matlab must have the netcdf tools installed, % see http://crusty.er.usgs.gov/mexcdf.html if needed % Created 11/25/98 by C. Moore % (use the next 3 lines to initialize netcdf interaction) %cd ~/bin %ncstartup %cd ~/data/temp clear for n=1:11 n % % open netcdf file, and create the vrml header % indir='../iso/lat_lon/'; outdir='data/'; if n<10 filei=[indir,'980',int2str(n),'_iso20_xy_lf.cdf']; fileo=[outdir,'980',int2str(n),'_iso20gs.wrl']; else filei=[indir,'98',int2str(n),'_iso20_xy_lf.cdf']; fileo=[outdir,'98',int2str(n),'_iso20gs.wrl']; end f=netcdf(filei,'nowrite'); ncclose(filei); data=f{6}(:); lat=f{4}(:); lon=f{5}(:); % % Print header to output vrml (.wrl) file % fid=fopen(fileo,'w'); fprintf(fid,'#VRML V2.0 utf8\n'); fprintf(fid,'# created by mkiso.m - Chris Moore\n'); fprintf(fid,'# 11/30/98\n'); fprintf(fid,'Transform {\n'); fprintf(fid,' children [\n'); fprintf(fid,' Shape {\n'); % uncomment the next line for transparency fprintf(fid,' appearance Appearance {material Material{transparency 0.6}}\n'); fprintf(fid,' geometry IndexedFaceSet {\n'); fprintf(fid,' solid FALSE\n'); fprintf(fid,' coord Coordinate {\n'); fprintf(fid,' point [\n'); % % do not use bad data: in this case, data greater than 1000 are bad % BADDATA=1.0e4; % % lat/lon to vrml coordinates (adjust scale to taste) scale=4; x=0:scale:(length(lon)-1)*scale; y=0:-scale:-(length(lat)-1)*scale; % % Save the points to vrml file % note: we 'invert' the data to give depth in the -y direction % INVERT = -1.0; pointnum=ones(length(lon),length(lat)); count=0; for l=1:length(lat), for k=1:length(lon), if (data(l,k)