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
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 |
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
-
The COPY command fails if:
- The shapefile cannot be located or opened.
- The number of columns or the data types of the columns that STV_ShpParser creates do not match the columns in the destination table. Use STV_ShpCreateTable to generate the appropriate CREATE TABLE command.
- One of the mandatory files is missing or cannot be opened. When opening a shapefile, you must have three files:
.dbf
,.shp
, and.shx
.
- If the
.shp
and.shx
files are corrupt, STV_ShpSource returns an error. If the.shp
and.shx
files are valid, but the.dbf
file is corrupt, STV_ShpSource ignores the.dbf
file and does not create columns for that data. - Any rejected records are saved in the /CopyErrorLogs directory under the catalog directory.
-
If the
.dbf
component of a shapefile contains a numeric attribute, this field's values may lose precision when the Vertica Place shapefile loader loads it into a table. The target field is a 64-bit FLOAT column, which can only represent about 15 significant digits; in a.dbf
file, Numeric fields can be up to 30 digits.
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