Dbf

Dbf files are dBase files, used as part of the esri-shapefile or as separate data file.

In reading and writing dbf files, the value types of the values units of the attributes should match with the data types of the attributes in the dbf file.

The following value types can be used for dbf data:

  • (u)int8/16/32/64 for byte, integer and long integer
  • float32/64 for single/double
  • bool for boolean
  • string for string

Other data/value types can not be read from (e.g. date) or written to (e.g. all Point Group types) dbf storages.

Read

The GeoDMS supports two ways of reading dbf files:

  • gdal.vect: we advice to use the gdal.vect StorageManager to read dbf files as it supports segmented data, see the next subparagraph.
  • dbf StorageManager

gdal.vect

The following example shows how to read a .dbf file with gdal.vect.

example:

unit<uint32> table: StorageName = "%projDir%/data/DBF.dbf"
,  StorageType     = "gdal.vect"
,  StorageReadOnly = "True"
{
  attribute<int32>   IntegerAtt;
  attribute<float32> FloatAtt;
  attribute<bool>    BoolAtt;
  attribute<string>  StringAtt;
}

dbf storagemanager

The following example shows how to read a .dbf file with the dbf storagemanager.

example:

unit<uint32> table: StorageName = "%projDir%/data/DBF.dbf"
,  StorageReadOnly = "True"
{
   attribute<int32>   IntegerAtt;
   attribute<float32> FloatAtt;
   attribute<bool>    BoolAtt;
   attribute<string>  StringAtt;
}

Write

The GeoDMS supports two ways of writing dbf files:

  • gdalwrite.vect: we advice to use the gdalwrite.vect StorageManager to write dbf files see the next subparagraph.
  • dbf StorageManager

Be aware: the names of attributes written to a .dbf file may not exceed 10 characters, as the .dbf file does not support longer fields.

We advise to write attributes to dbf file that do not have null values, as strange results might occur. Use the makedefined function to convert null values to a specific missing data value for your dbf file.

gdal.vect

The following example shows how to write a .dbf file with the gdalwrite.vect.

example:

unit <uint32> pc6_export := src/pc6
,  StorageName     = "%localDataProjDir%/export_table.dbf"
,  StorageType     = "gdalwrite.vect"
,  StorageReadOnly = "false"
{
   attribute<uint32>  IntegerAtt := const(1, .);
   attribute<float32> FloatAtt   := const(1f, .);
   attribute<string>  StringAtt  := const('A', .);
   attribute<bool>    BoolAtt    := const(true, .);
}

dbf storagemanager

The following example shows how to write a .dbf file with the dbf storagemanager.

example:

unit <uint32> pc6_export := src/pc6
,  StorageName     = "%localDataProjDir%/export_table.dbf"
,  StorageReadOnly = "false"
{
   attribute<uint32>  IntegerAtt := const(1, .);
   attribute<float32> FloatAtt   := const(1f, .);
   attribute<string>  StringAtt  := const('A', .);
   attribute<bool>    BoolAtt    := const(true, .);
}