Converting a Coverage to a Shapefile


The following example converts a coverage feature class (region) into a new shapefile with the proper feature type. The "canada" coverage from the data folder of the developer's samples is converted.

NOTE: to successfully run this script, you may need to modify the drive letter for the path to the input coverage data if it differs from where you installed the developer's samples.

How to use:
  1. Modify the code to fit your data.
  2. Paste the code into your VBA Application.
Sub CovertoShape()
 ' use IFeatureDataConverter::Convertfeatureclass to go from
 ' a coverage to shapefile
 ' Setup the output dataset
  Dim pPropset As IPropertySet
  Dim pOUTshwsname As IWorkspaceName
  Dim pOutShFCName As IFeatureClassName
  Dim pOutshDSName As IDatasetName
  Dim pInCovWorkspaceName As IWorkspaceName
  Dim pInFCName As IFeatureClassName
  Dim pCovDatasetName As IDatasetName
  Dim pCovtoshape As IFeatureDataConverter

  Set pPropset = New PropertySet
  pPropset.SetProperty "DATABASE", "D:\data\canada"

  Set pOUTshwsname = New WorkspaceName
  pOUTshwsname.ConnectionProperties = pPropset
  pOUTshwsname.WorkspaceFactoryProgID = "esriCore.shapefileWorkspaceFactory.1"
  ' create a new feature datset name object for the output
  ' canshape is a new shapefile polyline
  Set pOutShFCName = New FeatureClassName
  Set pOutshDSName = pOutShFCName
  Set pOutshDSName.WorkspaceName = pOUTshwsname = "canshape"
  ' now get the name object for the input coverage feature dataset name.
  Set pInCovWorkspaceName = New WorkspaceName
  pInCovWorkspaceName.pathname = "D:\data\canada"
  pInCovWorkspaceName.WorkspaceFactoryProgID = "esriCore.ArcInfoWorkspaceFactory.1"
  Set pInFCName = New FeatureClassName
  Set pCovDatasetName = pInFCName = "canada:region.prov"
  Set pCovDatasetName.WorkspaceName = pInCovWorkspaceName
  ' now use the conversion function convert the coverage to an Access feature dataset
  Set pCovtoshape = New FeatureDataConverter
  pCovtoshape.ConvertFeatureClass pInFCName, Nothing, Nothing, pOutShFCName, Nothing, Nothing, "", 1000, 0
  MsgBox "Coverage conversion complete!"
End Sub