ESRI Shapefile

ESRI Shapefiles are used to store vector-data and related attribute data.

The ESRI Shapefile format always consists of (at least) three accompanying files, with the extensions:

  • .shp: containing the geographical coordinates (feature-attribute).
  • .shx: containing a spatial index.
  • .dbf: containing tabular information describing the shapes. If a logical entity (like countries) consists of multiple shapes, the relation between the shapes and the logical entity is usually stored in this .dbf file.

Optionally a .prj file is als available, containing the projection information. This file is at the moment not (yet) used by the GeoDMS (projection information is configured explicitly in the GeoDMS).

The GeoDMS supports at the moment (multi)point, arc and polygon types (Shape types: 1,3, 5 and 8).

Read

The GeoDMS supports two ways of reading ESRI Shapefiles:

  • gdal.vect: for most shape files, we advice to use gdal.vect (see next subparagraph) to read csv files as it:
    • is faster
    • is more generic
    • is shorter to configure
    • supports open options
    • supports segmented data (If the file has more than 50.000 records, tiled-domain with segments of maximum 50.000 entries will be made)
  • shapefile/dbf storagemanager

gdal.vect

examples

how to configure reading point, polygon and arc data with gdal.vect:
unit<uint32> location
:  StorageName = "%projDir%/vectordata/points.shp"
,  StorageType = "gdal.vect"
{
   attribute<point_rd> geometry;
   attribute<string>   name;
}

unit<uint32> region
:  StorageName = "%projDir%/vectordata/region.shp"
,  StorageType = "gdal.vect"
{
   attribute<point_rd> geometry (polygon);
   attribute<string>   name;
}

unit<uint32> road
:  StorageName = "%projDir%/vectordata/road.shp"
,  StorageType = "gdal.vect"
{
   attribute<point_rd> geometry (arc);
   attribute<string>   name;
}
The .shp file is configured as [storagename](storagename.html) for the [domain-unit](domain-unit.html). The .dbf and .shx files are not explicitly configured, but need to be available in the same folder as the .shp file. The difference between the configuration of points, arcs and polygons is the configured [composition type](composition.html). If your dbf file already contains an attribute named geometry, use another attribute name for the data from the .shp file, for instance geom.

options

gdal-options can be configured for reading different ESRI Shapefiles.

See: https://gdal.org/drivers/vector/shapefile.html#open-options for a full list of all open options.

shapefile/dbf StorageManager

Shapefiles can also still be read with the GeoDMS specific shapefile/dbf StorageManagers (mainly for backward compatibility).

examples

how to configure reading point, polygon and arc data with shapefile/dbf StorageManager:
unit<uint32> location: StorageName = "%projDir%/data/location.dbf"
{
   attribute<point_rd> geometry: StorageName = "%projDir%/data/location.shp";
   attribute<string>   name;
}

unit<uint32> region: StorageName = "%projDir%/data/region.dbf"
{
   attribute<point_rd> region (polygon): StorageName = "%projDir%/data/region.shp";
   attribute<string>   name;
}

unit<uint32> road:  StorageName = "%projDir%/data/road.dbf"
{
   attribute<point_rd> geometry (arc): StorageName = "%projDir%/data/road.shp";
   attribute<string>   name;
}
The dbf file is configured as StorageName of the domain unit. The number of elements is read from this file. The feature attribute with the coordinates is configured as subitem of the domain unit. This attribute is read from the explicitly configured .shp file. The .shx file is not configured, the file needs to be available in the same folder as the .shp file. The difference between the configuration of points, arcs and polygons is the configured [composition type](composition.html).

Write

The GeoDMS supports two ways of writing ESRI Shapefiles:

  • gdalwrite.vect: for most shape files, we advice to use gdalwrite.vect (see next subparagraph) to write csv files as it:
    • is faster
    • is more generic
    • is shorter to configure
    • supports open options
  • shapefile/dbf StorageManager

gdalwrite.vect

examples

how to configure writing point, polygon and arc data with gdal.vect:
unit<uint32> location := SourceData/location
,  StorageName = "%LocalalDataProjDir%/export/points.shp"
,  StorageType = "gdalwrite.vect"
{
   attribute<point_rd> geometry := SourceData/location/geometry;
   attribute<string>   name     := SourceData/location/name;
}

unit<uint32> region := SourceData/region
:  StorageName = "%projDir%/vectordata/region.shp"
,  StorageType = "gdalwrite.vect"
{
   attribute<point_rd> geometry (polygon) := SourceData/region/geometry;
   attribute<string>   name               := SourceData/region/name;
}

unit<uint32> road
:  StorageName = "%projDir%/vectordata/road.shp"
,  StorageType = "gdalwrite.vect"
{
   attribute<point_rd> geometry (arc) := SourceData/road/geometry;
   attribute<string>   name           := SourceData/road/name;
}
The [feature-attribute](feature-attribute.html) is written to the .shp file (in the examples _geometry_). All other attributes (with supported .[dbf](dbf.html) [value types](value-type.html)) are written to a filename with the same name and a .dbf extension. This applies to both the direct as the indirect [subitems](subitem.html). If multiple subitems with a PoinGroup [value-type](value-type.html) occur, an error is generated. Set the [disablestorage](disablestorage.html) [property](property.html) to True for the attributes you do not want to be written to the.dbf file. A index file is also written together with the .shp file, with the same name but with the .shx extension. The difference between the configuration of points, arcs and polygons is the configured [composition type](composition.html).

options

gdal-options can be configured for writing different ESRI Shapefiles.

See: https://gdal.org/drivers/vector/shapefile.html#layer-creation-options for a full list of all creation options.

example on how to configure a write option:
container with_index
{
   unit<uint32> optionSet := range(uint32, 0, 1);
   attribute<string> GDAL_LayerCreationOptions (optionSet) : ["SPATIAL_INDEX=YES"];

   unit<uint32> location := SourceData/location
   ,  StorageName = "%LocalalDataProjDir%/export/points.shp"
   ,  StorageType = "gdalwrite.vect"
   {
      attribute<point_rd> geometry := SourceData/location/geometry;
      attribute<string>   name     := SourceData/location/name;
   }
}
This example shows how to export an ESRI Shapefile with a spatial index file (.qix) extensie.

shapefile/dbf StorageManager

Shapefiles can also still be written with the GeoDMS specific shapefile/dbf StorageManagers (mainly for backward compatibility).

examples

how to configure writing point, polygon and arc data with shapefile/dbf StorageManager: The example shows how to export an ESRI Shapefile with a spatial index file (.qix) extensie. Furthermore the resulting .dbf file is resized to an optimal size, this we advice especially for all ESRI Shapefiles to keep the size of the .dbf file limited.
container export
{
   unit<uint32&gt optionSet := range(uint32, 0, 2);
   attribute<string> GDAL_LayerCreationOptions (optionSet) : ["SPATIAL_INDEX=YES","RESIZE=YES"];

   unit<uint32> location := SourceData/location, StorageName = "%projDir%/data/location.dbf"
   {
      attribute<point_rd> geometry := SourceData/Location/geometry, StorageName = "%projDir%/data/location.shp";
      attribute<string>   name     := SourceData/Location/name;
   }
   
   unit<uint32> region := SourceData/region, StorageName = "%projDir%/data/region.dbf"
   {
      attribute<point_rd> region (polygon) := SourceData/region/geometry,  StorageName = "%projDir%/data/region.shp";
      attribute<string>   name             := SourceData/region/name;
   }

   unit<uint32> road := SourceData/road,  StorageName = "%projDir%/data/road.dbf"
   {
      attribute<point_rd> geometry (arc) := SourceData/road/geometry, StorageName = "%projDir%/data/road.shp";
      attribute<string>   name           := SourceData/road/name;
   }
}
The dbf file is configured as StorageName of the domain unit. The attributes (with supported .[dbf](dbf.html) [value types](value-type.html)) are written to the .dbf file with this filename. The feature attribute is written to the explicitly configured .shp file. An index file is also written together with the .shp file, with the same name but with the .shx extension. The difference between the configuration of points, arcs and polygons is the configured [composition type](composition.html).