Spatial Utilities

This chapter describes utilities provided by Tibero Spatial: gisLoader, tibero2shp, and shp2tibero.

gisLoader

Tibero Spatial provides gisLoader, an independent executable utility that loads shapefile format spatial data to Tibero.

The gisLoader utility reads data from a shapefile to create a data file that is used as an input file for tbLoader. That is, gisLoader converts a shapefile to a tbLoader input file, and then tbLoader loads the spatial data to Tibero.

Since .shx files are not interpreted by gisLoader, the shapefile information in .shx files is lost. Null, Point, Polyline, Polygon, and Multipoint are the shape types of a shapefile that can be interpreted by gisLoader. If a shapefile contains an unsupported shape type, gisLoader stops and outputs an error.

gisLoader generates only .ctl (control) and .dat (data) files, which are tbLoader input files. gisLoader does not generate schema scripts that can create tables. Therefore, a user must check the data in the generated control file to verify that data can be successfully loaded with tbLoader. For example, if a table does not exist, it must be created in advance to load data.

The following is a sample .ctl file created by gisLoader.

LOAD DATA
     INFILE 'test_table.dat'
     LOGFILE 'test_table.log'
     BADFILE 'test_table.bad'
     APPEND
     INTO TABLE test_table
     FIELDS TERMINATED BY ','
     OPTIONALLY ENCLOSED BY '"'
     ESCAPED BY '\\'
     LINES TERMINATED BY '\n'
     LOBFILE LOAD PARTIALLY DELIMITED BY ';'
     GEOMETRY LOAD AS BLOB
     (ID, FIPSSTCO, TRACT2000, BLOCK2000, STFID, geom OUTFILE)

If a table that will be used to load data does not exist, use the "create table" statement to create a table in advance.

CREATE TABLE test_table (ID number, FIPSSTCO number, TRACT2000 number,
BLOCK2000 number, STFID number, geom GEOMETRY);

For more information about tbLoader, refer to "Tibero Utility Guide".

Usage

The following describes how to use gisLoader.

  • Usage

gisLoader <shapefile name> <table name> <idcol=newcolname> <endian=big/little>
<multipolygon=[default:Y|N]>
Item
Description

shapefile name

Name of a .shp file that already exists.

table name

Name of a table in the database where data is loaded with tbLoader.

idcol

Name of a column that is created using the record number of a .shp file, not a .dbf

file. If omitted, a new column is not created.

endian

Endian information (big or little) to be used in the created geometry type. The default value is the endian of the machine.

multipolygon

Option to convert the polygon type of the .shp file to the multipolygon type. Set to N to convert to the polygon type.

  • Example

gisLoader test.shp test_table idcol=pk endian=little multipolygon=N


tibero2shp

Tibero Spatial provides tibero2shp, an independent executable utility that directly accesses a database and saves tables' GEOMETRY in shapefile format.

The tibero2shp utility exports GEOMETRYs that are Tibero query results to create a shapefile. Query result GEOMETRY can be a return value of a GEOMETRY function that selects a table's GEOMETRY column or takes a column as an argument and returns GEOMETRY.

Since a shapefile can include only a single type of GEOMETRYs, query results to load must have the same type of GEOMETRYs.

GEOMETRY types that can be loaded in a shapefile are POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, and MULTIPOLYGON. Note that the POINT type is distinguished from the MULTIPOINT type so that the two types cannot be loaded together. However, LINESTRING can be loaded along with MULTILINESTRING, and POLYGON can be loaded along with MULTIPOLYGON. LINESTRING GEOMETRYs are loaded to a shapefile as MULTILINESTRING, and POLYGON GEOMETRYs are loaded to a shapefile as MULTIPOLYGON.

Usage

The following describes how to use tibero2shp.

  • Usage

tibero2shp <option>
         <username>/<password>@<database name>
         <query>
Item
Description

option

Option to use.

username

Database user name.

password

Database user password.

database name

Database name.

query

Query of specifying GEOMETRY to be loaded to a shapefile. Query results must have the same type of GEOMETRYs.

  • Options

Option
Description

-f, --file

Name of a shapefile to create. (Default value: shape) .shp, .shx, and .dbf files are created with the specified name. The shapefile's path can be specified. If a file name is specified without a path, the file is created in the path where the command is executed.

-g, --geom

Name of a column to convert to a shapefile when there are multiple GEOMETRY columns in a table. (Default value: geom)

-h, --help

Displays the help page.

  • Example

tibero2shp -f $TB_HOME/testshape tibero/tmax@tibero
        "SELECT GEOM FROM GIS WHERE ST_GEOMETRYTYPE(GEOM)='POLYGON'"


shp2tibero

Tibero Spatial provides shp2tibero, an independent executable utility that loads shapefile to a database table.

The shp2tibero utility creates a table that corresponds to a shapefile.

GEOMETRY types that can be saved in a shapefile are POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, and MULTIPOLYGON.

Usage

The following describes how to use shp2tibero.

  • Usage

shp2tibero <option>
        <username>/<password>@<database name>
        <shapefile>
Item
Description

option

Option to use.

username

Database user name.

password

Database user password.

database name

Database name.

shapefile

Name of a .shp file that already exists.

  • Options

Option
Description

-t, --table

Name of a table to convert a shapefile to. The default value is the same name with the shape file.

-f, --file

Name of a shapefile to create. (Default value: shape) .shp, .shx, and .dbf files are created with the specified name. The shapefile's path can be specified. If a file name is specified without a path, the file is created in the path where the command is executed.

-d, --drop

Option to drop a table that has the same name with a table to create. If this option is enabled, the existing table is dropped and a new table is created with the name.

-i, --idcolumn

Name of an ID column of a table to create.

-e, --endian

Endian information (big or little) to be used in the created geometry type. The default value is the endian of the machine.

-p, --polygon

Option to not convert the type of GEOMETRY objects from POLYGON to MULTIPOLYGON. If this option is enabled, POLYGON type objects are not converted to MULTIPOLYGON.

-h, --help

Displays the help page.

  • Example

shp2tibero -t tablename tibero/tmax@tibero
        testshape

Last updated