| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Mapping Toolbox |
| Contents | Index |
| Learn more about Mapping Toolbox |
attribspec = makeattribspec(S)
attribspec = makeattribspec(S) analyzes a geographic data structure S and constructs an attribute specification suitable for use with kmlwrite. kmlwrite, given geostruct input, constructs an HTML table that consists of a label for the attribute in the first column and the string value of the attribute in the second column. You can modify attribspec, and then pass it to kmlwrite to exert control over which geostruct attribute fields are written to the HTML table and the format of the string conversion.
attribspec is a scalar MATLAB structure with two levels. The top level consists of a field for each attribute in S. Each of these fields, on the next level, contains a scalar structure with a fixed pair of fields:
| AttributeLabel | A string that corresponds to the name of the attribute field in the geographic data structure. With kmlwrite, the string is used to label the attribute in the first column of the HTML table. The string may be modified prior to calling kmlwrite. You might modify an attribute label, for example, because you want to use spaces in your HTML table, but the attribute field names in S must be valid MATLAB variable names and cannot have spaces themselves. |
| Format | The sprintf format character string that converts the attribute value to a string. |
Import a shapefile representing tsunami (tidal wave) events reported between 1950 and 2006 and tagged geographically by source location, and construct a default attribute specification (which includes all the shapefile attributes):
s = shaperead('tsunamis', 'UseGeoCoords', true);
attribspec = makeattribspec(s)
attribspec =
Year: [1x1 struct]
Month: [1x1 struct]
Day: [1x1 struct]
Hour: [1x1 struct]
Minute: [1x1 struct]
Second: [1x1 struct]
Val_Code: [1x1 struct]
Validity: [1x1 struct]
Cause_Code: [1x1 struct]
Cause: [1x1 struct]
Eq_Mag: [1x1 struct]
Country: [1x1 struct]
Location: [1x1 struct]
Max_Height: [1x1 struct]
Iida_Mag: [1x1 struct]
Intensity: [1x1 struct]
Num_Deaths: [1x1 struct]
Desc_Deaths: [1x1 struct]Modify the attribute specification to
Display just the attributes Max_Height, Cause, Year, Location, and Country
Rename the Max_Height field to Maximum Height
Display each attribute's label in bold type
Set to zero the number of decimal places used to display Year
Add "Meters" to the Height format, given independent knowledge of these units
desiredAttributes = ...
{'Max_Height', 'Cause', 'Year', 'Location', 'Country'};
allAttributes = fieldnames(attribspec);
attributes = setdiff(allAttributes, desiredAttributes);
attribspec = rmfield(attribspec, attributes);
attribspec.Max_Height.AttributeLabel = '<b>Maximum Height</b>';
attribspec.Max_Height.Format = '%.1f Meters';
attribspec.Cause.AttributeLabel = '<b>Cause</b>';
attribspec.Year.AttributeLabel = '<b>Year</b>';
attribspec.Year.Format = '%.0f';
attribspec.Location.AttributeLabel = '<b>Location</b>';
attribspec.Country.AttributeLabel = '<b>Country</b>';Use the attribute specification to export the selected attributes and source locations to a KML file as a Description:
filename = 'tsunami.kml';
kmlwrite(filename, s, 'Description', attribspec, ...
'Name', {s.Location})A view of Southeast Asia produced by the Google Earth application shows the selected, formatted attributes displayed for a 2006 tsunami in Indonesia.

kmlwrite, makedbfspec, shapewrite
![]() | majaxis | makedbfspec | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |