Create DBF specification
shapewrite function creates a main file
.shp), an index file (
.shx), and an attribute file
.dbf). Use a DBF specification with the
shapewrite function and
argument to specify which attribute fields to include in the DBF file, the length of each
field, and the numerical precision of each field.
Import a shapefile representing a network of road segments in Concord, MA, as a geospatial table. Create a DBF specification from the table.
GT = readgeotable("concord_roads.shp"); dbfspec = makedbfspec(GT)
dbfspec = struct with fields: STREETNAME: [1x1 struct] RT_NUMBER: [1x1 struct] CLASS: [1x1 struct] ADMIN_TYPE: [1x1 struct] LENGTH: [1x1 struct]
ADMIN_TYPE field from the specification, rename the
STREETNAME field to
Street Name, and reduce the number of decimal places used to store road lengths.
dbfspec = rmfield(dbfspec,"ADMIN_TYPE"); dbfspec.STREETNAME.FieldName = "Street Name"; dbfspec.LENGTH.FieldDecimalCount = 1;
Export the road network to a new shapefile.
S— Vector geographic features
Vector geographic features, specified as one of these:
A geospatial table. The
makedbfspec function does not
support geospatial tables containing more than one type of shape object. For more
information about geospatial tables, see Create Geospatial Tables.
A map structure array (
Y coordinate fields.
A geographic structure array (
dbfspec— DBF specification
DBF specification, returned as a structure array with two levels. The top level
contains a field for each attribute in
S. Each field in the top
level contains a scalar structure with four fields.
Field name for the
Field type for the
Number of bytes each instance of the field occupies in the file.
Number of digits to the right of the decimal place. Specify the
number of digits as
You can change the structure array before using it with the
shapewrite function. For example, you can remove attributes from
the structure or change the
FieldName field to include spaces.