Select to view content in your preferred language

How to check if spatial reference system is GCS or PCS?

899
1
12-15-2010 01:25 PM
PaulSchmidt1
New Contributor
Hi,
for an application I have to get the unit of the coordinate system of a featureClass. (I'm using VBA)

What I do is: I take the layer with the FeatureClass. Then give the Layer to IGeoDataset. The Reference System of the dataset I pass to IGeographicCoordinateSystem or IProjectedCoordinateSystem. Finaly i get the unit from IUnit.

My problem is: Bevor I pass to IGeographicCoordinateSystem or IProjectedCoordinateSystem, I have to know, if it is a GCS or a PCS. Otherwise I get an error.

I didn't find out how I can check this before.

Does anyone of you have an idea?
0 Kudos
1 Reply
MelitaKennedy
Esri Notable Contributor
Hi,
for an application I have to get the unit of the coordinate system of a featureClass. (I'm using VBA)

What I do is: I take the layer with the FeatureClass. Then give the Layer to IGeoDataset. The Reference System of the dataset I pass to IGeographicCoordinateSystem or IProjectedCoordinateSystem. Finaly i get the unit from IUnit.

My problem is: Bevor I pass to IGeographicCoordinateSystem or IProjectedCoordinateSystem, I have to know, if it is a GCS or a PCS. Otherwise I get an error.

I didn't find out how I can check this before.

Does anyone of you have an idea?


You should be able to use something like this:

    If TypeOf pSpatialReference Is IGeographicCoordinateSystem Then
        MsgBox "GeographicCoordinateSystem"
    End If
    
    If TypeOf pSpatialReference Is IUnknownCoordinateSystem Then
        MsgBox "UnknownCoordinateSystem"
    End If
    
    If TypeOf pSpatialReference Is IProjectedCoordinateSystem Then
        MsgBox "ProjectedCoordinateSystem"
    End If


Melita
0 Kudos