How to cut an envelope from File Geodatabase and save it as a shape file + C#

361
0
03-05-2012 07:54 AM
MukundaRao_R
New Contributor
hi,

I am in need to cut an envelope from the File Geodatabase and save it as a shape file.

I have done till opening the File GeoDB and finding the parcel count for the Envelope Area as shown below

public static IWorkspace FileGdbWorkspaceFromPropertySet(String path)
        {
            //Initialize the application.
            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
            IAoInitialize m_AoInitialize = new AoInitializeClass();
            licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);           
           
            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
            IWorkspaceFactory2 workspaceFactory = (IWorkspaceFactory2)Activator.CreateInstance
                (factoryType);
            return workspaceFactory.OpenFromFile(path, 0);
        }

IWorkspace featureWorkspace = FileGdbWorkspaceFromPropertySet(@"D:\Test.gdb");
IFeatureWorkspace fws = (IFeatureWorkspace)featureWorkspace;
IFeatureClass parcelsFeatureClass = fws.OpenFeatureClass("COParcels")

IEnvelope envelope = new EnvelopeClass();
              envelope.PutCoords(-106.9988, 38.7141, -107.0281, 38.701);

ISpatialFilter spatialFilter = new SpatialFilterClass();
              spatialFilter.Geometry = envelope;
              spatialFilter.GeometryField = parcelsFeatureClass.ShapeFieldName;
              spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
              spatialFilter.SubFields = "Shape";

int parcelCount = parcelsFeatureClass.FeatureCount(spatialFilter);


But i requirement is to save the Envelope area as a shape file.

Any help will be appreciated!
0 Kudos
0 Replies