I am using code in Matlab that writes xy coordinates and an associated z-value to a .txt file. However, I have been converting these .txt files to .shp point files and matching .shp polygon files in ArcMap 10. How could I update the attached code segment to output .shp files rather than .txt files so that I can skip a processing step? Thanks in advance.
[flout] = strread(fileName, '%s', 'delimiter','.')
outfilename = [outputdir 'Coords_' char(flout(1)) '.txt'];
fid2 = fopen(outfilename, 'wt');
fprintf(fid2, 'x,y,z,\n'); % Adds x,y,z, as a header
fclose(fid2);
dlmwrite(outfilename,Listpos4,'-append','delimiter',',', 'precision', '%.5f');
You actually need to create three files, not just the .shp. There’s also the index (.shx) and attributes (.dbf) files. The formats aren’t that difficult (Wikipedia has the basic format for .shp/.shx) but they are all binary formats.
It might be easier to write a python script using ArcPy to import the .txt file and export it as .shp, rather than trying to write your own shapefile.