how to write long field name in a shape file?

4 views (last 30 days)
Hello everyone , I need to write new column in a shape file so I used setfield function
SumOfLightColumn=char(SumOfLightColumn);%%convert it to character because it is a cell araay
n=num2cell(a); %%convert the a column vector from double to cell array so i can write in the table
s=setfield(shapeToTable,SumOfLightColumn,n); %%n is a after convertion to a cell array
w = table2struct(s);
shapefile1=fullfile(shapeFolder,baseShape); %%this the the path of the shape file
but the output of the field name is :Sum20150201 and when I run it for the second time it writes another column :Sum201502011 it doesn't take the whole name like this :Sum20150201_20150228
Does anyone know how to fix this? the attachment is a screenshot of the output shape file

Accepted Answer

Rachana Reddy Mamilla
Rachana Reddy Mamilla on 2 Aug 2018
Hello Reema, You cannot create fields whose size is greater than 11 characters using shapefile. Hence you face that issue. As you keep adding a column with the same field name, it keeps adding with a subscript. Ex. A file once saved as shape if you try to resave it, it gets saved as shape (1), shape(2) etc. It’s similar to this. You can refer to “When should I not use a shape file” in

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!