ArcSDE vs. oracle Spatial 4

导入数据到Oracle Spatial

Oracle Spatial并没有像ArcGIS那样有一套从桌面到数据库到服务器到开发包的全方位GIS产品体系,因此向Oracle中加载数据相比用ArcGIS要麻烦得多,同时也没有那么多的数据源格式的支持。Oracle本身则提供了一个工具shp2sdo[1] ,可以帮助你导入Shapefile到Oracle Spatial中,这个工具的使用分三个步骤:

第一步,使用shp2sde工具生成脚本和数据:

[oracle@test2 shp2sdo_linux]$ ./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): /home/wuyf/world/cities

Shape file /home/wuyf/world/cities.shp contains 2539 points

Output table [/home/wuyf/world/cities]: cities

Output data model [O]:

Geometry column [GEOM]:

ID column []:

Points stored in SDO_POINT_TYPE ? [Y]:

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=[-176.151564,179.221888] Y=[-54.792000,78.200001]

Override ? [N]:

Processing shapefile /home/wuyf/world/cities into spatial table CITIES

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 : 2539 points processed

The following files have been created:

cities.sql : SQL script to create the table

cities.ctl : Control file for loading the table

cities.dat : Data file

第二步,在数据库中执行shp2sdo生成的.sql脚本:

SQL> @/home/oracle/shp2sdo_linux/cities.sql

第三步,使用SQL*Loader加载shp2sdo生成的.ctl数据:

[oracle@test2 shp2sdo_linux]$ sqlldr spatial/esrichina cities.ctl

SQL*Loader: Release 11.2.0.1.0 - Production on 星期一 4月 19 14:02:26 2010

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

达到提交点 - 逻辑记录计数 64

达到提交点 - 逻辑记录计数 128

达到提交点 - 逻辑记录计数 192

达到提交点 - 逻辑记录计数 256

达到提交点 - 逻辑记录计数 320

达到提交点 - 逻辑记录计数 384

达到提交点 - 逻辑记录计数 448

导入成功后我们可以在Oracle Spatial中看到这个空间表,其中GEOM是导入时设置的几何字段,我们可以打印些数据看一下:

SQL> select geom from cities where rownum<10;

GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)

------------------------------------------------------------------------------------------------------------------------

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-66.348, -33.316002, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-57.140001, -25.387002, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-56.428002, -25.452999, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-57.150999, -25.623999, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-56.450997, -25.784001, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-58.176999, -26.182998, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-58.295997, -26.867997, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-58.986999, -27.457002, NULL), NULL, NULL)

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(-58.817997, -27.486999, NULL), NULL, NULL)

已选择9行。

至于其它一些第三方的工具,能作数据导入的估计也有不少,不过同时也免费估计就够呛了。


[1] http://www.oracle.com/technology/software/products/spatial/index.html

你可能感兴趣的:(oracle,sql,linux,脚本)