[SOLVED]Is there a way to get full extent of polygon without looping through features

587
2
09-23-2011 08:14 AM
WoodrowFields
New Contributor
This is hopefully an easy one for someone but my searches have given up nothing on the subject.

Is there a way to get the maximum extent of a polygon shapefile without looping through each of the features in the featureclass? 

I have a polygon with 100,000+ features in it.  I want to have the maximum extent of the polygon for another operation I am doing.  It seems silly and time consuming that I would have to loop through every single feature to get the maximum extent.

Please help.

Thanks!
0 Kudos
2 Replies
AlexanderGray
Occasional Contributor III
The featureclass class implements the IGeodataset that has an extent property, is this what you are looking for?
0 Kudos
WoodrowFields
New Contributor
That was the trick, thanks a million agray1.

so for anyone else scratching their heads on this one here is the code snippet

Dim pFWS As IFeatureWorkspace
Dim pWSF As IWorkspaceFactory
Set pWSF = New ShapefileWorkspaceFactory
Set pFWS = pWSF.OpenFromFile("C:\Temp", 0)

Dim pfeatureclass As IFeatureClass
Set pfeatureclass = pFWS.OpenFeatureClass("PolyShapefileName")

Dim pgeodataset As IGeoDataset
Set pgeodataset = pfeatureclass
x1 = pgeodataset.Extent.XMax 'this is the right most point of the polygon extent


Thanks!
0 Kudos