Select to view content in your preferred language

Export to shape file using ArcSDE C API

904
6
05-25-2011 10:27 PM
Udaya_BhaskerCheerala
Emerging Contributor
Hi All,

I have a point feature class in SDE geodatabase. And few other tables in SQL server database.
I need to join these table to point feature class and export to shape file using ArcSDE C API.
Can anyone help me how to achieve this task.

If not possible using ArcSDE C API, what is the best way to solve it. And also without using sde2shp command

Thanks,
Uday
0 Kudos
6 Replies
VinceAngelo
Esri Esteemed Contributor
How many weeks are you willing to devote to this task? Coding this yourself from scratch
can be expected to take 5-8 weeks, dependng on how thorough a job you need to do.

The ArcSDE 'C' API does not have shapefile access routines. It can generate the '.shp' file
features (SE_shape_as_binary), but you'd have to code all the rest, including the file headers,
the '.shx' contents, and '.dbf' layout (and conversion for the attributes). The spatial index
format for shapefiles used by ArcGIS is not documented anywhere.

The 'sde2shp' command, combined with 'sdetable -o create_view', is the most robust (and
supported) way to accomplish this goal. The 'sdequery' utility (found in se_toolkit) has
native ability to define a multi-table join, alias the columns, and export as a shapefile;
if you don't want to use 'sde2shp', then I'd recommend that instead.

Shapefiles are very nearly archaic. They don't support NSTRING international characters,
numeric nulls, or dates at finer than "day" resolution. When I need to copy data between
instances in a format that allows coordinate reference change (e.g., not 'sdeexport'), I use
ASCII files (also created by 'sdequery'). I'm working on using the File Geodatabase API
to add FGDB creation to 'sdequery' on Windows and Linux platforms.

- V
0 Kudos
Udaya_BhaskerCheerala
Emerging Contributor
Hi Vince,

Thank you very much for the reply. As you suggested I would like to go with 'sde2shp' command, combined with 'sdetable -o create_view' option. But how to join tables which are exist in another SQL Server database with the feature class exists in ArcSDE?

Thanks,
Uday
0 Kudos
VinceAngelo
Esri Esteemed Contributor
While not supported, the easiest way is to create empty templates of the tables in
the current database, use 'sdetable -o create_view' to build the spatial view, and
then edit the view definition to point to the other databases.

If the table uses GEOMETRY/GEOGRAPHY, then just define the view yourself, and
register the result with 'sdelayer -o register'.

- V
0 Kudos
Udaya_BhaskerCheerala
Emerging Contributor
While not supported, the easiest way is to create empty templates of the tables in
the current database, use 'sdetable -o create_view' to build the spatial view, and
then edit the view definition to point to the other databases.

If the table uses GEOMETRY/GEOGRAPHY, then just define the view yourself, and
register the result with 'sdelayer -o register'.

- V



Hi Vince,
Thank you very much for the response.  Iam doing this task as you suggested (first create view and export it to shape file). Iam able to create view and Iam able to see point feature class in arc catalog. When I try to to export this view(feature class) to shape file Iam getting the following error


C:\Documents and Settings\Administrator>sde2shp -o init -l Wells,shape -f E:
\Wells.shp -t point -i 5151 -a all -u wysde -p wysde

ArcSDE 9.1 SQL Server  Build 2101 Thu Mar  3 18:55:48 PST 2005
Layer Features to Shape File     Administration Utility
-----------------------------------------------------
Truncating column FACILITYNAME to a width of 254 from 255.
Unable to create shape attribute table,
invalid dBASE column definition.
Use "-a file=filename" option to modify the output definition.

Shape Attribute Columns: 23
Name         Type       Width    Decimal Places
------------ ----       -----    --------------
PRIORITYTI     D           8            -
PERMITSTAT     C          50            -
TOWNSHIP       C           3            -
TNS_SUFFIX     C           1            -
RANGE          C           3            -
RNG_SUFFIX     C           1            -
SECTION        C          10            -
QUARTER        C          50            -
QUARTERQUA     C          50            -


I did not find syntax help for sde2shp -a file=filename anywhere.

Could you please help me how to rectify this error.

Note: Spatial view having more than 4lac. records.


Thanks,
Uday
0 Kudos
VinceAngelo
Esri Esteemed Contributor
The format of the 'file=' file is documented with both 'shp2sde' and 'sde2shp', though
it's unlikely the full range of features documented for 10.0 online were available at 9.1.
You'll need to look in your local documentation for the features avaliable.

Given that you are working with a view, it makes more sense to construct the view that
will cause the least trouble at export (including limiting the column names to 10 characters).

What does 'sdetable -o describe' report on your view?

- V
0 Kudos
Udaya_BhaskerCheerala
Emerging Contributor
The format of the 'file=' file is documented with both 'shp2sde' and 'sde2shp', though
it's unlikely the full range of features documented for 10.0 online were available at 9.1.
You'll need to look in your local documentation for the features avaliable.

Given that you are working with a view, it makes more sense to construct the view that
will cause the least trouble at export (including limiting the column names to 10 characters).

What does 'sdetable -o describe' report on your view?

- V


Hi Vince,

Finally my problem is solved Iam able to export SDE feature class to shape using -a file option.
Thank you very much for your support.

Thanks,
Uday
0 Kudos