| Contents | Index |
shapewrite(S, filename)
shapewrite(S, filename, 'DbfSpec',
dbfspec)
shapewrite(S, filename) writes a geographic data structure to disk in shapefile format. shapewrite creates three output files: [basename '.shp'], [basename '.shx'], and [basename '.dbf'], where basename is filename without its extension. If a given attribute is integer-valued for all features, then it is written to the [basename '.dbf'] file as an integer. If an attribute is non-integer-valued for any feature, then it is written as a fixed point decimal value with six digits to the right of the decimal place.
shapewrite(S, filename, 'DbfSpec', dbfspec) writes a shapefile in which the content and layout of the DBF file is controlled by a DBF specification, indicated here by the parameter value dbfspec.
The xBASE (.dbf) file specifications require that geostruct and mapstruct attribute names are truncated to 11 characters when copied as DBF field names. Consider shortening long field names before calling shapewrite. By doing this, you make field names in the DBF file more readable and avoid introducing duplicate names as a result of truncation.
Remember to set your character encoding scheme to match that of the geographic data structure you are exporting. For instance, if you are exporting a map that displays Japanese text, configure your machine to support Shift-JIS character encoding.
Derive a shapefile from concord_roads.shp in which roads of CLASS 5 and greater are omitted. Note the use of the 'Selector' option in shaperead, together with an anonymous function, to read only the main roads from the original shapefile.
shapeinfo('concord_roads') % 609 features
ans =
Filename: [3x67 char]
ShapeType: 'PolyLine'
BoundingBox: [2x2 double]
NumFeatures: 609
Attributes: [5x1 struct]
S = shaperead('concord_roads', 'Selector', ...
{@(roadclass) roadclass < 4, 'CLASS'});
shapewrite(S, 'main_concord_roads.shp')
shapeinfo('main_concord_roads') % 107 features
ans =
Filename: [3x24 char]
ShapeType: 'PolyLine'
BoundingBox: [2x2 double]
NumFeatures: 107
Attributes: [5x1 struct]makedbfspec | shapeinfo | shaperead

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