Tuesday, January 22, 2008

SDO_GEOMETRY Layers and -g Option in ArcSDE Commands

“-g” option in some ArcSDE administration commands is used to specify particularities for creating a spatial index, such as “sdelayer -o add”.

For ArcSDE to store geometries in Oracle Spatial’s SDO_GEOMETRY data type, there are three types of spatial indexes: RTREE, FIXED and HYBRID. Oracle and ESRI recommend using RTREE spatial indexes since Oracle 9i. So “-g RTREE” is used in ArcSDE commands that accept “-g” option.

SDO_GEOMETRY layers cannot use the grid-based spatial index used with ArcSDE compressed binary storage.

Examples:

-- load shapefile to a layer of SDO_GEOMETRY
shp2sde -o create -l sdo_layer,shape -f shape_file -a all -g RTREE -e a -u SDE_USER

-- register a SDO_GEOMETRY table as an ArcSDE layer
sdelayer -o register -l sdo_layer,GEOM -e a+ -g RTREE -C OBJECTID,USER -R 2 -i 5151 -s sde_server -u sde_user

Refer to ESRI Technical Article 26511.

Get Area and Length of Features Stored in Oracle Spatial

The area and length of features are not pre-calculated and stored by Oracle’s SDO_GEOMETRY data type constructor functions. SDO_GEOMETRY type does not have places to store area and length values.

Geometric functions SDO_GEO.SDO_AREA and SDO_GEOM.SDO_LENGTH can be used to calculate the values in SQL queries when needed.

-- calculate the area
SELECT OBJECTID, SDO_GEOM.SDO_AREA(SHAPE, 0.005) FROM THE_LAYER;

-- calculate the length
SELECT OBJECTID, SDO_GEOM.SDO_LENGTH(SHAPE, 0.005) FROM THE_LAYER;

0.005 is the tolerance.