Workflow: Creating an ArcObjects raster field

Complexity: Advanced Data Requirement: Use your own data Goal: Create and populate a nonspatial raster field and prepare it for access by ArcGIS.

Some applications display imagery, such as pictures of traffic signs, rivers, or buildings, to further illustrate a point, line, or polygon feature. These images may or may not be spatially referenced. You can use SQL to create a table with a nonspatial raster column.

The following workflow describes how to create and populate a raster column and prepare it for access by ArcGIS.

Create and populate a table with a raster column

Steps:
  1. Connect to the database from a SQL editor.

    For example, connect to Oracle from SQL*Plus, to PostgreSQL from pgAdminIII or the psql command prompt, or to Microsoft SQL Server from Management Studio.

  2. Create a table with an ST_Raster column.

    Oracle

    CREATE TABLE real_estate (address nvarchar2(255),
    sde.st_raster picture);

    PostgreSQL

    CREATE TABLE real_estate (address varchar(255), 
    sde.st_raster picture);

    SQL Server

    CREATE TABLE real_estate (address varchar(255), 
    dbo.st_raster picture);

    If your geodatabase in SQL Server is stored in the sde user's schema, preface the function with sde.

  3. Use the ST_Raster_Util_Initialize method to initialize the raster column.

    In these examples, the projectID argument is null because the data is not spatially referenced.

    Oracle

    BEGIN
    SDE.ST_RASTER_UTIL.INITALIZE ('real_estate','picture',NULL,'defaults');
    END;
    /

    PostgreSQL

    SELECT st_raster_util_initialize  
    ('real_estate','address',4326,'DEFAULTS');

    SQL Server

    EXEC dbo.st_raster_util_initialize 
    'sde','bobby','real_estate','address',4326,NULL,'DEFAULTS'

    Once this method executes, the raster column is registered with ArcSDE and available to its functionality.

  4. Convert a TIFF image using the ST_Raster constructor.

    In these examples, a picture of the property at 30551 Independence Ave is entered into the real_estate table by converting the TIFF image file, 30551_independence, with the ST_Raster constructor.

    Oracle

    INSERT INTO REAL_ESTATE (address, sde.st_raster)
    VAULES
    ('30551 Independence  Ave',
    SDE.ST_RASTER('C:\30551_independence.tif','compression=lz77'));
    

    PostgreSQL

    INSERT INTO real_estate (address, sde.st_raster)
    VAULES
    ('30551 Independence Ave',  
    sde.st_raster('C:\30551_independence.tif'));

    SQL Server

    INSERT INTO real_estate (address, dbo.st_raster)
    VALUES
    ('30551 Independence Ave',
    ST_Raster::construct('C:\30551_independence.tif'));
    TipTip:

    Be sure the path to the image is one the database server can access.

  5. You can insert additional data to this table.

Add a registered row ID to the table

To cursor through the rows of an ArcSDE table, ArcGIS needs an ArcSDE registered row ID column (also called an ObjectID) in the table. You can use the sdetable command to add the row ID.

Steps:
  1. Run the sdetable command with the alter_reg operation to add a row ID column to the table that is registered with ArcSDE.

    Oracle

    sdetable -o alter_reg -t real_estate -c objectid -C SDE 
    -i sde:oracle11g -s myserver -u tblowner -p ulook.away -N

    PostgreSQL

    sdetable -o alter_reg -t real_estate -c objectid -C SDE -N
    -i sde:postgresql:myserver -s myserver -D pgdb -u tblowner -p ulook.away 

    SQL Server

    sdetable -o alter_reg -t real_estate -c objectid -C SDE -N
    -i sde:sqlserver:myserver\ssinstance -D ssdb -u tblowner -p ulook.away 

    The rasters of this table can now be viewed through the ArcGIS Desktop user interface.

If you want to be able to edit the table in ArcGIS, or you want the table to participate in any geodatabase functionality, such as subtypes or relationship classes, you must register it with the geodatabase.

Registering the table with the geodatabase

Use ArcGIS Desktop to register the table with the geodatabase.

Steps:
  1. Start ArcMap and open the Catalog window or start ArcCatalog.
  2. Connect to the ArcSDE geodatabase that contains the table you want to register.

    This connection is made under the Database Connections node of the Catalog tree. Be sure you connect as the owner of the table.

  3. Right-click the real_estate table.
  4. Click Register with Geodatabase.
  5. You will be prompted to choose the existing ObjectID field or create a new one.
  6. Choose to use the objectid field you added using the sdetable command.
  7. Click OK.

Related Topics


2/5/2013