Is there a way to get the longitude and latitude coordinates from a feature class? I have some code which can select the first layer in the Table of Contents. I want to be able to get the lat./long. of a feature in that layer (any lat./long. within the Data Frame's current extent will do).
With a point file I can see this being pretty straightforward (using the IPoint interface), but how would I go about do this with a polygon?
(Bonus points to anyone who can tell me if I can get the lat./long. using a FactoryCode!)
Here's my code thus far:
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pTargetFL As IFeatureLayer
Dim pTargetGD As IGeoDataset
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
Set pTargetFL = pMap.Layer(0) 'Set the IFeatureLayer as the first layer in the TOC
Set pTargetGD = pTargetFL.FeatureClass
Dim pTargetSR As ISpatialReference
Dim pGeoDatasetEdit As IGeoDatasetSchemaEdit
Dim pSpatRefFact As ISpatialReferenceFactory
Dim pProjCoordSys As IProjectedCoordinateSystem
Set pTargetSR = pTargetGD.SpatialReference 'Set the spatial reference object
Dim fatCode As Integer
fatCode = pTargetSR.FactoryCode
MsgBox ("Layer Name: " & pTargetFL.Name & vbNewLine & "Layer Projection: " & pTargetSR.Name & vbNewLine & "Factory Code: " & fatCode)