how to write long field name in a shape file?

조회 수: 2 (최근 30일)
Reema Alhassan
Reema Alhassan 2018년 7월 18일
답변: Rachana Reddy Mamilla 2018년 8월 2일
Hello everyone , I need to write new column in a shape file so I used setfield function
SumOfLightColumn=strcat('Sum','20150201_20150228');
SumOfLightColumn=char(SumOfLightColumn);%%convert it to character because it is a cell araay
shapeToTable=struct2table(shape);
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
shapewrite(w,shapefile1);
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

채택된 답변

Rachana Reddy Mamilla
Rachana Reddy Mamilla 2018년 8월 2일
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 http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Geoprocessing_considerations_for_shapefile_output

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by