You are on page 1of 2

JAVA SHAPEFILE CONVERTER

DESCRIPTION
The Java Shapefile Converter transforms an ESRI Shapefile into an Oracle database table
for use with Oracle Spatial and Locator. The Shapefile Converter uses the Oracle Spatial
Java-based Shapefile Adapter and SampleShapefileToJGeomFeature classes to load a
Shapefile directly into a database table, with the Oracle-equivalent .dbf data types for the
attribute columns and the SDO_GEOMETRY data type for the geometry column. The
Shapefile Adapter can also be used to create your own applications and interfaces that
transform Shapefiles to SDO_GEOMETRY or JGeometry data types (see the Oracle
Spatial Java API for more information). To simply load a Shapefile into the database, use
the SampleShapefileToJGeomFeature class as illustrated below.

NOTES
The requirements for using the Shapefile Converter or Shapefile Adapter are:
• An Oracle10g or later database with Locator or Oracle Spatial
• A user/password account for the database
• The Oracle utilities and JDBC libraries (JARs):ojdbc14.jar or ojdbc5.jar, sdoutl.jar,
and sdoapi.jar
• Sun JDK version 1.4.2_04 or higher: JDK 1.5 is required for Oracle 11g
• ESRI Shapefile(s) (.shp, .shx, and .dbf files) to be converted

USAGE
> java -cp [ORACLE_HOME]/jdbc/lib/ojdbc5.jar:./sdoutl.jar:./sdoapi.jar
oracle.spatial.util.SampleShapefileToJGeomFeature -h db_host -p db_port -s db_sid -u
db_username -d db_password -t db_table -f shapefile_name [-i table_id_column_name][-
r srid][-g db_geometry_column][-x max_x,min_x][-y max_y,min_y][-o tolerance]

Explanation of usage parameters:


• -h: Host machine with existing Oracle database
• -p: Host machine's port (e.g. 1521)
• -s: Host machine's SID
• -u: Database user
• -d: Database user's password
• -t: Table name for the converted Shapefile
• -f: File name of an input Shapefile (without extension)
• -i: Column name for unique numeric ID; if required
• -r: Valid Oracle SRID for coordinate system; use 0 if unknown
• -g: Preferred SDO_GEOMETRY column name
• -x: Bounds for the X dimension; use -180,180 if unknown
• -y: Bounds for the Y dimension; use -90,90 if unknown
• -o: Load tolerance fields (x and y) in metadata, if not specified, tolerance fields
are 0.05
• -a: Append Shapefile data to an existing table
• -n: Start ID for column specified in -i parameter
• -c: Commit interval. Default, commits every 1000 conversions and at the end
• -v: Println interval. Default, displays every 10 conversions

Linux Example:
> setenv clpath
$ORACLE_HOME/jdbc/lib/ojdbc5.jar:$ORACLE_HOME/md/jlib/sdoutl.jar:$ORACLE
_HOME/md/jlib/sdoapi.jar
> java -cp $clpath oracle.spatial.util.SampleShapefileToJGeomFeature -h gis01 -p 1521 -
s orcl -u scott -d tiger -t states -f states -r 8307 -g geom

Windows Example:
> java -classpath
%ORACLE_HOME%\jdbc\lib\ojdbc5.jar;%ORACLE_HOME%\md\jlib\sdoutl.jar;%OR
ACLE_HOME%\md\jlib\sdoapi.jar oracle.spatial.util.SampleShapefileToJGeomFeature -
h gis01 -p 1521 -s orcl -u scott -d tiger -t states -f states -r 8307 -g geom

You might also like