Featurelayer to Geometry

529
1
Jump to solution
03-01-2012 10:56 AM
Highlighted
New Contributor III
In c# .net how to I get the geometry of a feature layer using arcobjects? Its probably simple but i'm new to this. I tried to cast to it but i didn't work.
below is a quick sample.

IFeatureClass pEventFC;
pName = (IName) pRESN;

pEventFC = (IFeatureClass) pName.Open();

IActiveView pActive;
pFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pEventFC;

IGeometry pGeom;

pGeom = (IGeometry)pFlayer

Any clues?
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Regular Contributor III
A feature layer doesn't have a geometry.  A feature layer contains features, each of which have a geometry.  You can get the features from a feature layer via a query.  The query can be an attribute query or a spatial query.  Here is one example.

Dim featureCursor As IFeatureCursor = featureLayer.FeatureClass.Search(Nothing, False) Dim feature As IFeature = featureCursor.NextFeature Do While feature IsNot Nothing     Dim geometry As IGeometry = feature.ShapeCopy     feature = featureCursor.NextFeature Loop

View solution in original post

Reply
0 Kudos
1 Reply
Highlighted
Regular Contributor III
A feature layer doesn't have a geometry.  A feature layer contains features, each of which have a geometry.  You can get the features from a feature layer via a query.  The query can be an attribute query or a spatial query.  Here is one example.

Dim featureCursor As IFeatureCursor = featureLayer.FeatureClass.Search(Nothing, False) Dim feature As IFeature = featureCursor.NextFeature Do While feature IsNot Nothing     Dim geometry As IGeometry = feature.ShapeCopy     feature = featureCursor.NextFeature Loop

View solution in original post

Reply
0 Kudos