Loading Spatial Data from Shapefiles

Vertica provides the capability to load and parse spatial data that is stored in shapefiles. Shapefiles describe points, lines, and polygons. A shapefile is made up of three required files; all three files must be present and in the same directory to define the geometries:

  • .shp—Contains the geometry data.
  • .shx—Contains the positional index of the geometry.
  • .dbf—Contains the attributes for each geometry.

To load spatial data from a shapefile:

  1. Use STV_ShpCreateTable to generate a CREATE TABLE statement.
    => SELECT STV_ShpCreateTable ( USING PARAMETERS file = '/home/geo/temp/shp-files/spatial_data.shp') 
                                   OVER() AS spatial_data;
    spatial_data
    ----------------------------------
    CREATE TABLE spatial_data(
    gid IDENTITY(64) PRIMARY KEY,
    uniq_id INT8,
    geom GEOMETRY(85)
    );
    (5 rows)
  2. Create the table.
    => CREATE TABLE spatial_data(
    gid IDENTITY(64) PRIMARY KEY,
    uniq_id INT8,
    geom GEOMETRY(85));
  3. Load the shapefile.
    => COPY spatial_data WITH SOURCE STV_ShpSource(file='/home/geo/temp/shp-files/spatial_data.shp') 
        PARSER STV_ShpParser();
    Rows Loaded
    -------------
    10
    (1 row)

Supported Shapefile Shape Types

The following table lists the shapefile shape types that Vertica supports.

Shapefile Shape Type Supported
Null shape Yes
Point Yes
Polyline Yes
Polygon Yes
MultiPoint Yes
PointZ No

PolylineZ

No

PolygonZ

No

MultiPointZ

No

PointM

No

PolylineM

No

PolygonM

No
MultiPointM No
MultiPatch No