sde2shp

The sde2shp command extracts features from an ArcSDE geodatabase feature class or log file and writes them to an ESRI shapefile.

Note: This function is not supported on 64-bit Windows, Linux, or HP-Itanium.

Usage syntax

From a feature class:

sde2shp -o append -l <table,column> [-V <version_name>]
-f <shape_file> -t <file_type> [-a {all | file=<file_name>}]
[-w <"where_clause">] [-i {<service> | <port#> | <direct connection>}]
[-s <server_name>] [-D <database_name>] -u <DB_user_name>
[-p <DB_user_password>]
 

sde2shp -o init -l <table,column> [-V <version_name>]
-f <shape_file> -t <file_type> [-a {all | file=<file_name>}]
[-w <"where_clause">] [-i {<service> | <port#> | <direct connection>}]
[-s <server_name>] [-D <database_name>] -u <DB_user_name>
[-p <DB_user_password>]

From a log file:

sde2shp -o append -L <log_file> [-V <version_name>] -f <shape_file>
-t <file_type> [-a {all | file=<file_name>}] [-w <"where_clause">]
[-i {<service> | <port#> | <direct connection>}] [-s <server_name>]
[-D <database_name>] -u <DB_user_name> [-p <DB_user_password>]
 

sde2shp -o init -L <log_file> [-V <version_name>]-f <shape_file>
-t <file_type> [-a {all | file=<file_name>}] [-w <"where_clause">]
[-i {<service> | <port#> | <direct connection>}] [-s <server_name>]
[-D <database_name>] -u <DB_user_name> [-p <DB_user_password>]

sde2shp -h

sde2shp -?
 

Operations

Operation Description
append Adds the features to existing features in the shapefile

If the file does not already exist, it is created.

init Deletes the shapefile if it exists, then creates a new one

 

Options

Options Description
-a Attribute Modes

all: Loads all attribute columns

If an attribute table exists, the incoming schema must be union compatible with the shapefile's dBASE table if using the append operation.

file=<file_name>: File containing lines in 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. You can export feature table columns such as spatial_column.FID and spatial_column.AREA. The type, width, and nDec arguments refer to the dBase column format as follows:

description type width
Character C 1-254
Date D 8
Logical L 1
Numeric N 1-19

The number of decimal places can be any positive integer value that is less than the width.

-D Database name (not supported on Oracle)
-f Path to and name of the shapefile to add to or create
-h or -? Use either of these options to see the usage and options for the command. Note: If using a C shell, use -h or "-\?".
-i ArcSDE service name, port number, or direct connection information (default: esri_sde or 5151)
-l Input feature class table and spatial column name

These must exist, and the executing user must have read access. If you are not the owner of the table, you must qualify the table name as owner.table.

-L Name of the log file to extract from
-o Operation, such as append or init
-p DBMS user password
-s ArcSDE server host name (default: localhost)
-t Shapefile types (names are not case sensitive):

point: Accepts only point feature
pointZ: Accepts points, z-values, and measure values (optional)
pointM: Accepts points and measures

arc: Accepts line, simple line, and area features. Area features with donuts are accepted as multipart shapefile arc features
arcZ: Accepts linear features, z-values, and measure values (optional)
arcM: Accepts linear features and measures

polygon: Accepts area features
polygonZ: Accepts area features, z- values, and measure values (optional)
polygonM: Accepts area features and measures

multipoint: Accepts points and multipart points
multipointZ: Accepts points, multipoints, z-values, and measure values (optional)
multipointM: Accepts points, multipoints, and measure values

-u DBMS user name
-V Version name; if specified, uses only the data that belongs to the version, if not specified, uses the default version (default: sde.DEFAULT)

Version names are case sensitive; for example, SDE.DEFAULT is a different version from SDE.default.

-w SQL WHERE clause to limit the features retrieved from the business table or log file

WHERE clause must be enclosed in double quotes ("").

 

Conversion table

ArcSDE entity (feature) Output shape
point point (If the output shapefile is a multipoint type, each point feature is written out as a multipoint shape with one point.)
lines arc
simple lines arc
area polygon
multipart area multipart polygon

 

ArcSDE support for database file types

Type Width Description Storage
B 10 Binary field No
C 1-254 Character Yes
D 8 Date Field specified as 8 ASCII characters in YYYYMMDD format Yes
F 1-20 Numeric floating point field See below
G 10 General field No
L 1 Logical field Yes
M 10 Memo field No
N 1-19 Numeric fixed position field Yes
P 10 Picture field No
V 10 Variable field No

The dBase F-type column will not be created in the resultant shapefile, but ArcSDE will write to an existing F-type column. Therefore, the sde2shp init operation will not create an F-type column, but the sde2shp append operation will write into a shapefile containing an existing F-type. Conversely, the shp2sde command will read an F-type column.

 

Discussion

The sde2shp command converts ArcSDE geodatabase feature classes into shapefiles and can convert up to 15 digits of precision or the maximum precision imposed by the SE_DOUBLE data type. Note: Shapefiles have a 2 GB size limit.

The sde2shp command does not export rows with NULL geometries. Any row with a NULL geometry will be rejected. You will know if it was rejected because sde2shp reports the number of rows exported and number of rows rejected.

The sde2shp command also does not export UTF-8 text fields (Unicode) to shapefiles.

If you need to export the entire data source, you should use sdeexport. When using sdeexport, the NULL geometry and attributes are preserved and the sdeimport command will import the row with a NULL shape.

If the command encounters a feature class column name containing the characters # or -, it returns the error message:

Unable to create shape attribute table: Bad column definition

In such cases, use the DBMS SQL editor to rename the columns before converting them to a shapefile.

Note: If you have altered column definitions using a SQL interface while the data was stored in an ArcSDE geodatabase, exporting the data may fail. You could instead create a new column with an acceptable name that is of the same data type and length as the old column. Then, in an edit session in ArcMap, you can use the field calculator to copy the values from the old column to the new column. See the topic "Making field calculations" in the ArcGIS Desktop help for details on the field calculator.

 

Examples

Add features to a shapefile

Use the append operation to add features to an existing shapefile or to create a new shapefile and add features.

sde2shp -o append -l parks,shape -f parks -t polygon -u av

Delete an existing shapefile then re-create it

Use the init operation to delete an existing shapefile then convert a feature class to the shapefile. The example below deletes the shapefile census_data, then converts a feature class called blocks to the census_data shapefile.

sde2shp -o init -l blocks,shape -f census_data -t polygon -a all -u av

Create a new shapefile, specifying which features should be extracted from the ArcSDE feature class

You can use the WHERE clause to choose specific features from the ArcSDE feature class you want in the new shapefile. Here, only primary schools are being chosen from an ArcSDE feature class to create a shapefile called elementary.

sde2shp -o append -l schools,shape -f elementary -t point -w "type=primary" -u av -p secret

 

Home

Copyright © Environmental Systems Research Institute, Inc. 2004 - 2010.