English

How To: Use the sde2shp -a option to change shapefile attribute column definitions

Summary

Instructions provided describe how to use the sde2shp ArcSDE administrative command to export an ArcSDE feature class (layer) to a shapefile, while changing the attribute definitions.

Procedure

The sde2shp command extracts features from an ArcSDE feature class (layer) or log file and writes them to an Esri shapefile.

The -a (attribute) option controls whether attributes are exported, and if so, whether all or just some of the attributes are exported.

The -a option is defined as:
[-a {all | file=<file_name>}]

Where:
file=<file_name>: File containing lines of the form <sde_column> [shape_column] [type] [width] [nDec].

The sde_column selects the column to output. The remaining optional items determine the new attribute column definitions. It is possible to export feature table columns such as spatial_column.FID and spatial_column.AREA. By defining the file, one can optionally change the attribute column definition.

  • The format of 'file' used in the conversion is:
    Code:

    ----------------------------------
    dBASE colType width_in_bytes nDecPlaces
    N 1..19 /* Numeric field */
    C 1..254 /* Character field */
    D 8 /* Date field */
    L 1 /* Logical field */
    ----------------------------------

  • For example, describe the SDE table:

    % sdetable -o describe -t TestFC 
    ArcSDE 10.0 for SQL Server Build 685 Fri May 14 12:05:43 2010
    Attribute Administration Utility
    ------------------------------------------
    Table TestFC:
    Column name Attribute type Null? Length,DPs RowID Column?
    -------------------------------------------------------------------------------
    OBJECTID SE_INT32 NOT NULL 10 SDE Set
    Area SE_FLOAT64 NULL 38,8
    Perimeter SE_FLOAT64 NULL 38,8
    SHAPE SE_SHAPE NULL 0
    Name SE_NSTRING NULL 50


  • See the following to export the above layer plus OBJECTID, AREA, and LEN from the Business table.
    Conversion Control File: TestFC.exp

    Area ATTR_AREA n 12 1
    Perimeter ATTR_PERIMETER n 13 2
    Name ATTR_NAME c 13
    OBJECTID OBJECTID
    SHAPE.AREA SHAPE_AREA n 15 6
    SHAPE.LEN SHAPE_LEN n 19 9

  • Now do the export:

    Code:
    % sde2shp -o init -l TestFC,shape -f newshpfile -t polygon -a file=TestFC.exp

    ArcSDE 10.0
    Layer Features to Shape File Administration Utility
    -----------------------------------------------------
    WARNING: Possible loss of data when converting SE_NSTRING to ANSI string.
    Change ATTR_AREA col_def from N,19,8 to N,12,1
    Truncate column name to max length of 10 chars: "ATTR_PERIM"
    Change ATTR_PERIM col_def from N,19,8 to N,13,2
    Change ATTR_NAME col_def from C,50,0 to C,13
    Change SHAPE_AREA col_def from N,19,0 to N,15,6
    Change SHAPE_LEN col_def from N,19,0 to N,19,9
    3 features converted.
    0 features rejected.

Related Information