Exporting spatial data to a shapefile

Using the db2se export_shape command or the DB2GSE.ST_EXPORT_SHAPE procedure, you can export spatial data returned in query results to a shapefile.

Before you begin

Ensure that your user ID holds the following privileges:
  • Privilege to execute a subselect that returns the results that you want to export
  • Privilege to write to the directory where the file to which you will be exporting data resides
  • Privilege to create a file to contain the exported data (required if such a file does not already exist)

To find out what these privileges are and how to obtain them, consult your database administrator.

About this task

You can export spatial data from:
  • Base tables
  • Result sets returned from a query of a view
  • Result sets returned from a query of a join or union of multiple tables
  • Result sets returned from a spatial function

Procedure

To export data to a shapefile:

  1. Call the DB2GSE.ST_EXPORT_SHAPE procedure.
  2. Choose one of the following ways to export data to a shapefile:
    • Issue the db2se export_shape command.
    • Calls the DB2GSE.ST_EXPORT_SHAPE procedure.
  3. Optional: Verify the information and the content of shapefile by using the following command:
    db2se shape_info -fileName shapefile_name