STV_ShpSource and STV_ShpParser

These two functions work with a COPY command to parse and load the geometries and attributes from a shapefile into a database table and convert them to the GEOMETRY data type format. You must use these two functions together. An SRID is required. An empty multipoint or an invalid multipolygon can not be loaded from a shapefile.

Behavior Type

Immutable

Syntax

COPY table_name( col2, col3, ..., coln )
     WITH SOURCE STV_ShpSource( file = 'filename'[[, SRID=spatial reference identifier]
                                                     [, flatten_2d={true | false }] ] ) 
     PARSER STV_ShpParser()

Arguments

table_name

Name of the table in which to load the geometry data.

col1, col2, ...

Column names in the table that match the fields in the external file. Run the CREATE TABLE command that STV_ShpCreateTable creates. When you do so, these columns correspond to the second through the second-to-last columns.

file = 'filename'

Fully qualified path of the .dbf, .shp, or .shx file.

SRID=spatial reference identifier
Spatial reference identifier (SRID) associated with the shape file, type INTEGER.
flatten_2d

(Optional) BOOLEAN that excludes 3D or 4D coordinates during COPY commands.

True - Excludes geometries with 3D or 4D coordinates before a COPY command.

False - Causes the load to fail if a geometry with 3D or 4D coordinate is found.

Default: False

Usage Tips

Example

The following example shows how to use STV_ShpSource and STV_ShpParser.

=> COPY tl_2010_us_state10 WITH SOURCE
STV_ShpSource(file='/shapefiles/tl_2010_us_state10.shp', SRID=4269) PARSER STV_ShpParser();
 Rows loaded
-------------
          52