Thursday, January 17, 2008

Importing Shapefiles into Oracle

shp2sdo.exe is the conversion tool for the specific platform. It can be downloaded at Shape2SDO Download and is available in /home/oracle/shp2sdo on taifun. A readme file is there, too.

Running shp2sdo.exe (even on LINUX) without any command line parameter works fine. You'll be asked a couple of questions. Here's an example:

oracle@taifun:~/shp2sdo$ shp2sdo.exe
shp2sdo - Shapefile(r) To Oracle Spatial Converter
Version 2.15 21-May-2004
Copyright 1997,2004 Oracle Corporation
For use with Oracle Spatial.
Input shapefile (no extension): ../tmpdata/gg_limburg
Shape file ../tmpdata/gg_limburg.shp contains 47 polygons
Output table [../tmpdata/gg_limburg]: gg_limburg
Output data model [O]:
Geometry column [GEOM]:
ID column []:
Use a spatial reference system ID (SRID) ? [N]:
Change tolerance value from the default (0.00000005) ? [N]:
Generate data inside control files ? [N]:
Target database Oracle8i? [N]:
Spatial Data requires more than 6 digits precision? [N]:
Bounds: X=[167507.730000,213448.380000] Y=[306838.822000,421214.230000]
Override ? [N]:
Processing shapefile ../tmpdata/gg_limburg into spatial table GG_LIMBURG
Data model is object-relational
Geometry column is GEOM
Points stored in SDO_POINT attributes
Data is in a separate file(s)
Control file generation for Oracle9i or higher
Spatial data loaded with 6 digits of precision
Conversion complete : 47 polygons processed
The following files have been created:
gg_limburg.sql : SQL script to create the table
gg_limburg.ctl : Control file for loading the table
gg_limburg.dat : Data file

It does the same as:

shp2sdo.exe ../tmpdata/gg_limburg gg_limburg -g GEOM -s 90112

-- except that the -s parameter was specified here.

To load the data into Oracle...

oracle@taifun:~/shp2sdo$ sqlplus developer/dev @gg_limburg.sql
oracle@taifun:~/shp2sdo$ sqlldr developer/dev control=gg_limburg.ctl

1 comment:

Tani said...

Maybe everyone is just busy. Importing shapefiles into Oracle with the conversion tool for the specific platform can be made if parameters works fine.
sap upgrade planning

Some/All/Major of the blog content is not mine and i'm not the writer of it, all rights reserved to the authors.